[Python-ideas] Question about `list.insert`

Ram Rachum ram.rachum at gmail.com
Fri Feb 7 00:58:49 CET 2014


Oops, my mistake, I meant to post in python-list but accidentally posted 
here because it was in my favorites. Sorry, I'll post there.

On Friday, February 7, 2014 1:58:05 AM UTC+2, Ram Rachum wrote:
>
> Hi,
>
> I'm curious. If I append an item to a list from the left using 
> `list.insert`, will Python always move the entire list one item to the 
> right (which can be super-slow) or will it check first to see whether it 
> can just allocate more memory to the left of the list and put the item 
> there, saving a lot of resources?
>
>
> Thanks,
> Ram.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140206/a7fd3adb/attachment.html>


More information about the Python-ideas mailing list