[Python-Dev] Re: PEP 322: Reverse Iteration
Raymond Hettinger
python at rcn.com
Wed Nov 5 22:25:19 EST 2003
> > * There is a small group (including Jeremy Fincher) that consider a
> > reversal protocol to be essential.
>
> And I think that as a protocol it needs a separate PEP, because new
> protocols are much more involved than new builtins.
Great idea. The champions for __reverse__ can plead their case there.
> > * It is particularly useful for xrange() because it reduces the
overhead
> > to zero without touching the API. The implementation patch on SF
shows
> > that this can be done cleanly. Essentially, __reverse__ forwards
the
> > call to __iter__ with the arguments rearranged for reverse order.
>
> The implementation could special-case xrange() and lists and "optimize
> the snot out of them" without the need for a general protocol.
Agreed! I'll take __reversed__ out of the pep.
May I mark this one as accepted and move on?
Raymond Hettinger
More information about the Python-Dev
mailing list