A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-April/044152.html below:

[Python-Dev] More imformative iterator representations

[Python-Dev] More imformative iterator representations [Python-Dev] More imformative iterator representationsRaymond Hettinger python at rcn.com
Wed Apr 7 05:16:25 EDT 2004
> 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


More information about the Python-Dev mailing list

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