[issue32595] Deque with iterable object as one object

2018-01-19 Thread Jonathan

Jonathan  added the comment:

Hello,

I dont know why but yesterday when i appended it behaved like extend.
I should sleep more.

2018-01-18 20:27 GMT+00:00 Raymond Hettinger :

>
> Raymond Hettinger  added the comment:
>
> Sorry Jonathan, this is the way the python containers work if they take an
> iterable input.  In the case of a str, it is not possible for us to know
> whether you mean for deque('abc') to go it as three arguments or as one.
>
> FWIW, if you don't what to put the single element in a list, the API
> provides the append() method for adding scalars and extend() method for
> adding iterables:
>
>d = deque()
>d.append('abc')
>d.extend('abc')
>
> Note that lists behave the same way.
>
> --
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32595] Deque with iterable object as one object

2018-01-18 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Sorry Jonathan, this is the way the python containers work if they take an 
iterable input.  In the case of a str, it is not possible for us to know 
whether you mean for deque('abc') to go it as three arguments or as one.

FWIW, if you don't what to put the single element in a list, the API provides 
the append() method for adding scalars and extend() method for adding iterables:

   d = deque()
   d.append('abc')
   d.extend('abc')

Note that lists behave the same way.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32595] Deque with iterable object as one object

2018-01-18 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32595] Deque with iterable object as one object

2018-01-18 Thread Jonathan

New submission from Jonathan :

Creating a deque with an iterable object creates extra overhead if you want to 
insert it as one element.

e.g:
import timeit

test1 = '''
str = "x" * 10
lst = [str]
'''

test2 = '''
str = "x" * 10
'''

print(timeit.timeit(test1, number=10))
print(timeit.timeit(test2, number=10))

If I want to add a string to a deque i will have to put it in a list first, 
this causes 23% slower performance in my case.

There should be a deque where this overhead is not needed because in most cases 
this will be used in performance demanding cases.

--
components: Library (Lib)
messages: 310256
nosy: jonathandaniel
priority: normal
severity: normal
status: open
title: Deque with iterable object as one object
type: performance
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com