Comment on PEP-0322: Reverse Iteration Methods

David Eppstein eppstein at
Fri Sep 26 18:18:18 CEST 2003

In article <WNYcb.12686$yD1.1505440 at>,
 "Sean Ross" <sross at> 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            
Univ. of California, Irvine, School of Information & Computer Science

More information about the Python-list mailing list