[issue16398] deque.rotate() could be much faster

John O'Connor report at bugs.python.org
Sat Jan 12 00:41:52 CET 2013


John O'Connor added the comment:

Looking at the implementation (rather quickly)[1]. I'm wondering if there is a reason why the appendleft(pop()) loop is required. It would seem the best way would be to determine the new head link, make the previous link the new end link and concatenate the two chains (by just swapping some pointers).
        

[1]. http://hg.python.org/cpython/file/a4292889e942/Modules/_collectionsmodule.c#l429

----------

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


More information about the Python-bugs-list mailing list