list.pop(0) vs. collections.dequeue

Terry Reedy tjreedy at udel.edu
Fri Jan 22 16:32:47 EST 2010


On 1/22/2010 2:14 PM, Steve Howell wrote:
> The v2.6.4 version of the tutorial says this:

> Is that really true in CPython?  It seems like you could advance the
> pointer instead of shifting all the elements.  It would create some
> nuances with respect to reclaiming the memory, but it seems like an
> easy way to make lists perform better under a pretty reasonable use
> case.

Something like this was one proposed (ie, leave space at both ends of a 
list) but was rejected as over-complicating the list implementation for 
*relatively* rare use cases. I believe deque was written subsequently to 
address such other use cases.




More information about the Python-list mailing list