[issue18826] reversed() requires a sequence - Could work on any iterator?
Raymond Hettinger
report at bugs.python.org
Sun Sep 1 07:36:19 CEST 2013
Raymond Hettinger added the comment:
Sorry, Guido rejected this idea a long time ago. We do have the __reversed__ hook so you can add reverse iteration to your own classes where it makes sense.
Doing it in the general case is more problematic. Some data sources such as generators can't be run backwards so they would have to be run to exhaustion and saved in memory to support reversed iteration. If a user wants this behavior, it is trivial to achieve it by running reversed(list(it)). The user is in for unhappiness though if the underlying iterator is infinite or huge ;-)
----------
resolution: -> rejected
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18826>
_______________________________________
More information about the Python-bugs-list
mailing list