A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/039982.html below:

FW: [Python-Dev] PEP 322: Reverse Iteration

FW: [Python-Dev] PEP 322: Reverse Iteration FW: [Python-Dev] PEP 322: Reverse IterationRaymond Hettinger python at rcn.com
Tue Nov 4 19:49:06 EST 2003
> > I believe the assumption is that enumerate (as well as the proposed
> irange)
> > would grow an __reversed__ method to handle just that usage.

Unfortunately, that idea didn't work out.  The enumerate object does not
hold the original iterable; instead, it only has the result of
iter(iterable).  Without having the iterable, I don't see a way for it
to call iterable.__reversed__.  The essential problem that at creation
time, the enumerate object does know that it is going to be called by
reversed().

No other sequence object has to have a __reversed__ method.  Like its
cousin, __iter__, some objects may be a performance boost from a custom
iterator but none of them have to have it.


Raymond Hettinger


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4