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/2003-October/039619.html below:

[Python-Dev] RE: cloning iterators again

[Python-Dev] RE: cloning iterators again [Python-Dev] RE: cloning iterators againGuido van Rossum guido at python.org
Mon Oct 27 09:53:24 EST 2003
> But I don't understand how it would be quite messy to take advantage
> of this in tee(), either: simply, tee() would start with the equivalent of
>     it = iter(it)
>     try: return it, copy.copy(it)
>     except TypeError:pass
> and proceed just like now if this shortcut hasn't worked -- that's all.

Right, that's what the tee() at the end of my code did, except it
checked for __copy__ explicitly, since I assume that only iterators
whose author has thought about copyability should be assumed copyable;
this means that the default copy stategy for class instances (classic
and new-style) as suspect.

tee is more and less powerful than copy; it is more powerful because
it works for any iterator, but less so because you can't continue
using the underlying iterator (any calls to its next() method will be
lost for both tee'ed copies).

--Guido van Rossum (home page: http://www.python.org/~guido/)

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