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

David Abrahams David Abrahams" <david.abrahams@rcn.com
Mon, 15 Jul 2002 23:30:07 -0400


From: "Andrew Koenig" <ark@research.att.com>

> I wasn't suggesting defining a protocol for every possible iteration
> view.  I was raising the question of whether multi-pass iteration
> was likely to be a common enough operation that it is worth defining
> a protocol for it, while leaving the door open to defining protocols
> for others should it turn out to be desirable to do so.

I think your examples are confusing different beasts, then. Multipass
(=copyable in these examples) should be a capability of iterators, just as
bidirectional or random-access would be. Breadth-first/depth-first is not a
capability of the iterator in that sense, but an implementatoin detail --
from the POV of the iterator's user, there's no way to tell what the
traversal order is.

-Dave