A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-July/026219.html below:

[Python-Dev] Single- vs. Multi-pass iterability

[Python-Dev] Single- vs. Multi-pass iterabilityDavid Abrahams David Abrahams" <david.abrahams@rcn.com
Tue, 9 Jul 2002 05:37:47 -0400
From: "Alex Martelli" <aleax@aleax.it>


> On Tuesday 09 July 2002 10:57 am, Moore, Paul wrote:
> > IIRC from earlier discussions on the list, iterators "by design" do not
> > expose this information. In C++ terms, all Python iterators are forward
> > iterators
>
> I think they're _input_ iterators -- you can only "get" items through the
> iterator, not "set" them (as you can with forward, but not input,
> iterators in C++).

C++ also has forward constant iterators which are not writable. Take the
const_iterator type of your favorite singly-linked-list implementation for
example.

Unfortunately, C++ iterators mix up a bunch of concepts which ought to be
orthogonal, like single-vs-multipass, whether they iterate over lvalues or
must use a proxy, direction of iterability. Excellent paper on the topic at
http://groups.yahoo.com/group/boost/files/iterator-categories.html.


> The first step in studying such a need is whether it IS in fact a need.
> Sure, "rich iterators" might come in handy, but do we NEED them...?
> If so, then what kinds of rich-iterators do we in fact need?  How to get
> at them seems a third-order problem at best (and here, of course, I
> would suggest that adaptation IS good for this tertiary problem:-).


I don't know if we need them, but I'm certainly finding that not having
some more information is difficult for me. If I need to make multiple
passes over the information in a generalized iterable object, the only
solution AFAICT is to unconditionally copy all the information into a list
first.

-Dave








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