[New-bugs-announce] [issue17100] rotating an ordereddict
Antoine Pitrou
report at bugs.python.org
Fri Feb 1 17:32:03 CET 2013
New submission from Antoine Pitrou:
It can be useful to rotate an OrderedDict (for example when managing a circular playlist). I haven't found any efficient way to do so from user code, without poking at the internals.
Actually, I envision three methods:
OrderedDict.rotate(self, n):
rotate n steps to the right (similarly to deque.rotate())
OrderedDict.rotate_at(self, key):
rotate so that the given key ends up in first position
OrderedDict.rotate_after(self, key):
rotate so that the given key ends up in last position
(rotate_at, rotate_after could be merged in a single method with a "last" argument, if deemed more elegant)
Note: another solution to the playlist problem would be to have insert_after() and insert_before() methods.
----------
messages: 181086
nosy: pitrou, rhettinger
priority: normal
severity: normal
status: open
title: rotating an ordereddict
type: enhancement
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17100>
_______________________________________
More information about the New-bugs-announce
mailing list