Are there performance concerns with popping from front of long lists vs. the end of long lists?
Terry Reedy
tjreedy at udel.edu
Sun Jun 22 14:33:23 EDT 2014
On 6/22/2014 2:03 PM, python at bdurham.com wrote:
> Should I have any performance concerns with the index position used to
> pop() values off of large lists?
Yes. While performance is generally not part of the language
specification, in CPython seq.pop(i) is O(len(seq)-i)
> In other words, should pop(0) and pop() be time equivalent operations
> with long lists?
No. If you want this, use collections.deque.
--
Terry Jan Reedy
More information about the Python-list
mailing list