Comment on PEP-0322: Reverse Iteration Methods

David Eppstein eppstein at ics.uci.edu
Fri Sep 26 12:18:18 EDT 2003


In article <WNYcb.12686$yD1.1505440 at news20.bellglobal.com>,
 "Sean Ross" <sross at connectmail.carleton.ca> wrote:

> How about
> 
> from itertools import ireverse
> for i in ireverse(xrange(n)):
>     # suite
> 
> ireverse(), like imap(), izip(), etc., suggests that the operation is
> iterative, and that no modification of the original sequence will be
> performed. Others have suggested riter() (right iteration), in order to form
> an association with the iter() builtin. As a matter of taste, I prefer
> ireverse().

ireverse, like imap(), izip(), etc., suggests that the operation happens 
without the memory overhead of copying the whole sequence into a list 
before reversing it.  Do you have some plan for how to do that e.g. with 
simple generators?  Or easy to understand explanation for which things 
can be ireversed and which can't?

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-list mailing list