> 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4