[issue17100] rotating an ordereddict

Antoine Pitrou report at bugs.python.org
Sat Feb 2 08:56:56 CET 2013


Antoine Pitrou added the comment:

> It is trivial.
> 
> def rotate(od, n):
>     for i in range(n):
>         k, v = od.popitem(False)
>         od[k] = v

That's O(n), with many spurious insertions and deletions.

> And those functions look too specialized.

How so? rotating sounds quite generic to me. deques already allow
rotating.

----------

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


More information about the Python-bugs-list mailing list