PEP 322: Reverse Iteration (second revision, please comment)

Raymond Hettinger vze4rx4y at verizon.net
Thu Oct 30 03:00:08 EST 2003


Based on the feedback here on comp.lang.python, the pep has been
updated:

    www.python.org/peps/pep-0322.html


The key changes are:

* reversed() is being preferred to ireverse() as the best name.

* the sample implementation now clearly shows a check for a custom
  reverse method and a guard against being applied to a mapping.

* added sample output for enumerate.__reversed__ to show
  how a custom reverse method would work

* explained why the function is proposed as a builtin and why attachment
   to another module or type object is not being considered further.

* expanded comments on the real world use cases to show what the
   replacement code would look like.


Please continue to contribute your thoughts.  I'm especially interested
in people examining their own code to verify that the new function
adds clarity and improves performance.

Also, please take a look at the revrange() alternative to see if you
prefer it or not.


Raymond Hettinger








More information about the Python-list mailing list