[Python-Dev] More imformative iterator representations (original) (raw)
Raymond Hettinger python at rcn.com
Wed Apr 7 05:16:25 EDT 2004
- Previous message: [Python-Dev] More imformative iterator representations
- Next message: [Python-Dev] MS open sources WiX
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
Trees, dicts, and sets all know their length and can iterate sequentially without having random access. PyDict_Next() makes it easy to find the first 3 keys, but there is no general purpose way of finding the nth key without looping over them all.
Raymond
- Previous message: [Python-Dev] More imformative iterator representations
- Next message: [Python-Dev] MS open sources WiX
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]