On Friday, February 7, 2014 6:52:24 AM UTC+2, Dan Stromberg wrote: > On Thu, Feb 6, 2014 at 3:59 PM, cool-RR <ra...@gmail.com> wrote: > > I'm pretty sure it'll slide all the existing elements right one > position, and add at the leftmost position just opened up - assuming > you're inserting at position 0. > > As was already mentioned, collections.deque is good for this sort of > thing. It's implemented as a fancy doubly-linked list. Or rather, a > doubly-linked list of smallish arrays/lists. > For a singly-linked list: > http://stackoverflow.com/questions/280243/python-linked-list > http://stromberg.dnsalias.org/~strombrg/linked-list/ > > HTH
the Py list is just 2 members (as declared in corresponding header) structure where only one double pointer serves addressing towards most probably dynamically allocated array of pointers towards python objects. so adding could expensive as it should copy all pointers in array into new bigger one during expanding as array needs to be contiguous. so it looks more array than list. but i could be wrong in my conclusion. /Asaf -- https://mail.python.org/mailman/listinfo/python-list