[issue37770] implement __reversed__ on reversed types

Steven D'Aprano report at bugs.python.org
Mon Aug 5 21:53:49 EDT 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

Both 3.7 and 3.8 are in feature-freeze, so the earliest we can get this would be 3.9.

But before that, we have to decide on what reversing a reversed object means.

it = reversed([1, 2, 3, 4])
next(it)
list( reversed(it) )

Should that give [1, 2, 3] or [1, 2, 3, 4]? I think that either answer will annoy and surprise some people.

[1, 2, 3] will surprise those who expect to get the original iterable back. [1, 2, 3, 4] will surprise those who expect reversed to operate on the current state of an iterator, not it's previous state.

----------
nosy: +steven.daprano
versions: +Python 3.9 -Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37770>
_______________________________________


More information about the Python-bugs-list mailing list