PEP 323: Copyable Iterators

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Martelli

    PEP 323: Copyable Iterators

    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:

    This PEP suggests that some iterator types should support shallow copies of their instances by exposing a __copy__ method which meets some specific requirements, and indicates how code using an iterator might exploit such a __copy__ method when present.


    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

  • Gonçalo Rodrigues

    #2
    Re: PEP 323: Copyable Iterators

    On Wed, 29 Oct 2003 18:09:49 GMT, Alex Martelli <aleax@aleax.it >
    wrote:
    [color=blue]
    >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.
    >
    >[/color]

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

    With my best regards,
    G. Rodrigues

    Comment

    • John Roth

      #3
      Re: PEP 323: Copyable Iterators


      "Alex Martelli" <aleax@aleax.it > wrote in message
      news:NnTnb.6452 8$e5.2364423@ne ws1.tin.it...[color=blue]
      > 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[/color]
      vastly[color=blue]
      > extended as a consequence of discussions on these issues on python-dev.[/color]

      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


      Comment

      Working...