[Python-Dev] PEP 322: Reverse Iteration

Guido van Rossum guido at python.org
Tue Nov 4 18:44:27 EST 2003


> > option somehow.  But since (a) at least 60% of the examples are
> > satisfied with something like irevrange(), and (b) having irevrange()
> 
> I'm not sure it's as high as that, depending on how strictly one wants
> to define "satisfied".

There are 6 bullets in PEP 322's "real world use cases" section.  The
first one is not helped by reversed().  Of the remaining 5, three are
simple numeric ranges (heapq.heapify(), platform.dist_try_harder() and
random.shuffle()).  That's exactly 60%. :-)

>     for i, value in reversed(enumerate(listofnum)):

Sorry, this doesn't work.  enumerate() returns an iterator, reversed()
requires a sequence.

> > If you can prove it would be used as frequently as sum() you'd have a
> > point.
> 
> No, not as frequently as sum, but then this applies to many other
> builtins.

Well, they are already there, and we're considering removing some.
I'd like to set the bar for *new* builtins fairly high.  (You all know
the joke how Aspirin would never have been approevd by the FDA as an
over-the-counter drug if it was invented today.)

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list