iterator clone

Yosifov Pavel bulg at ngs.ru
Tue Jul 15 02:16:08 EDT 2008


On 14 июл, 23:36, "bruno.desthuilli... at gmail.com"
<bruno.desthuilli... at gmail.com> wrote:
> On 13 juil, 12:05, Yosifov Pavel <b... at ngs.ru> wrote:
> (snip)
>
> > defcloneiter( it ):
> >     """return (clonable,clone)"""
> >     return tee(it)
>
> This might as well be written as
>
> cloneiter = tee
>
> Or yet better, just remove the above code and s/cloneiter/tee/g in the
> remaining...

Yes, sure. It was only for illustration. BUT: Marc Rintsch is right:
cloning of iterators in this manner is bad, more good is to use one,
single list(my_iter) instead of (see
http://aquagnu.blogspot.com/2008/07/self-repair-iterator-in-python.html).

Thanks to all!

--pavel



More information about the Python-list mailing list