[Python-ideas] A cute Python implementation of itertools.tee

Koos Zevenhoven k7hoven at gmail.com
Mon Apr 16 05:03:44 EDT 2018


On Sun, Apr 15, 2018 at 11:55 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Mon, Apr 16, 2018 at 6:46 AM, Koos Zevenhoven <k7hoven at gmail.com>
> wrote:
> > Anyway, the whole linked list is unnecessary if the iterable can be
> iterated
> > over multiple times. But "tee" won't know when to do that. *That* is
> what I
> > call overhead (unless of course all the tee branches are consumed in an
> > interleaved manner).
>
> But if you have something you can iterate over multiple times, why
> bother with tee at all? Just take N iterators from the underlying
> iterable. The overhead is intrinsic to the value of the function.
>
>Indeed. But if you have, say, an Iterable[int], you don't know if you need
the additional buffer or not.  It could be a range object or a set or a
generator (or iterator), who knows. Even your type checker doesn't know
what you need.

-- Koos


-- 
+ Koos Zevenhoven + http://twitter.com/k7hoven +
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180416/b3c653b6/attachment.html>


More information about the Python-ideas mailing list