[New-bugs-announce] [issue16398] deque.rotate() could be much faster

Simon Law report at bugs.python.org
Sat Nov 3 20:31:06 CET 2012


New submission from Simon Law:

If you look at the implementation of deque.rotate(), it does the equivalent of deque.append(deque.popleft()) or deque.appendleft(deque.pop()).

Unfortunately, for larger rotations, the pop() and append() calls just do too much work. Since the documentation recommends using rotate() to do slicing-style operations, this could get seriously slow.

deque.rotate() could just touch up the internal pointers and use memmove() to realign the data.

Benchmarks, of course, would have to be written to make sure this is a win.

----------
components: Library (Lib)
messages: 174679
nosy: sfllaw
priority: normal
severity: normal
status: open
title: deque.rotate() could be much faster
type: performance
versions: Python 2.7, Python 3.2, Python 3.3

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


More information about the New-bugs-announce mailing list