[issue7784] patch for making list/insert at the top of the list avoid memmoves

Adam Olsen report at bugs.python.org
Wed Jan 27 00:34:09 CET 2010


Adam Olsen <rhamph at gmail.com> added the comment:

$ ./python -m timeit -s 'from collections import deque; c = deque(range(1000000))' 'c.append(c.popleft())'
1000000 loops, best of 3: 0.29 usec per loop

$ ./python -m timeit -s 'c = range(1000000)' 'c.append(c.pop(0))'
1000000 loops, best of 3: 0.424 usec per loop

Using flox's issue7784_listobject_perf.diff.  Significantly slower, but it does scale linearly.


$ ./python -m timeit -s 'c = range(1000000)' 'c.insert(0, c.pop())'
100 loops, best of 3: 3.39 msec per loop

Unfortunately inserting does not.  Will future patches attempt to address this?

Note that, if it ends up slower than list and slower than deque there isn't really a use case for it.

----------
nosy: +Rhamphoryncus

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7784>
_______________________________________


More information about the Python-bugs-list mailing list