lists and sequences

Bengt Richter bokr at
Tue Oct 15 22:41:18 CEST 2002

On Tue, 15 Oct 2002 12:18:04 -0700, Erik Max Francis <max at> wrote:

>Michal Vitecek wrote:
>>  why ditto for alist.pop(0)? is it because there can be multiple
>>  references to the same list/address?
>No, because aList.pop(0) removes the first element and shifts the rest
>down.  A list in Python is implemented as a vector, not a linked list.
I wonder how often that happens. If it happened a lot, I could see
a time optimization based on keeping an offset to the first element
in the allocated space and bumping that until there'se a worthwhile
chunk to shift down over. Of course insertions at the front could take
advantage of available space if any (in fact, you could anticipate repeat
insertions and allocate front space in chunks. It would add an int to
the list representation size though.

Bengt Richter

More information about the Python-list mailing list