PEP 323: Copyable Iterators

A

Alex Martelli

Interested parties (essentially, people who write user-coded iterator, or
are intense users of iterators as "stream of data", of standard library
module itertools, etc) are welcome to read, and possibly comment on, a new
PEP on copyable iterators, see:

http://www.python.org/peps/pep-0323.html

The PEP is currently at revision 1.2, having already been amended and vastly
extended as a consequence of discussions on these issues on python-dev.


In brief, the PEP proposes that:

iterator types supply a __copy__ method, if, and only if, the method can
make an independently iterable copy of their instances at reasonably low
cost in time and memory;

the new function itertools.tee be optimized to exploit this method if its
argument iterators support it;

existing built-in iterator types be upgraded to supply this __copy__ method
where applicable;

user-written code normally rely on itertools.tee to get independently
iterable iterators on the same underlying sequence (occasionally, for
special needs, user-written code may feature-test an iterator for __copy__,
as long as said user code wants to deal directly and in special ways with
both cases, that of copyable iterators and that of non-copyable iterators).


Alex
 
G

Gonçalo Rodrigues

Interested parties (essentially, people who write user-coded iterator, or
are intense users of iterators as "stream of data", of standard library
module itertools, etc) are welcome to read, and possibly comment on, a new
PEP on copyable iterators, see:

http://www.python.org/peps/pep-0323.html

The PEP is currently at revision 1.2, having already been amended and vastly
extended as a consequence of discussions on these issues on python-dev.

Ah, an easy choice for a change. A definite +1 and no comments from
me.

With my best regards,
G. Rodrigues
 
J

John Roth

Alex Martelli said:
Interested parties (essentially, people who write user-coded iterator, or
are intense users of iterators as "stream of data", of standard library
module itertools, etc) are welcome to read, and possibly comment on, a new
PEP on copyable iterators, see:

http://www.python.org/peps/pep-0323.html

The PEP is currently at revision 1.2, having already been amended and vastly
extended as a consequence of discussions on these issues on python-dev.

I don't see where I'd use it, but on the other hand it doesn't seem like it
would increase the complexity of Python much (if at all) and it does seem
like a rather obvious feature to have.

+1

John Roth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top