[Python-Dev] More imformative iterator representations

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Apr 6 23:52:29 EDT 2004


Bob Ippolito <bob at redivi.com>:

> This is essentially getting back to what Armin was saying.. if
> iterators act more like lists, they will be easier to user and will
> open up some new doors for optimization potential.  Adding a way to
> get the length of some iterators essentially makes them list-like or
> tuple-like.

But... if an iterator is sufficiently random-access to be able to
report its length and produce selected items without doing anything
irreversible, wouldn't it make more sense for it to be a (possibly
read-only) sequence rather than an iterator in the first place?

In other words, instead of e.g. dict.iteritems() there should be
a dict.itemseq() or something that returns a sequence-like view
of the dict.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-Dev mailing list