more fun with iterators (mux, demux)
python at rcn.com
Wed Apr 8 23:58:12 CEST 2009
> I assume that "smallish values of n" refers to the fact that
> itertools.tee places items into every generator's internal deque,
> which islice then skips over, whereas your version places items only
> into the deque of the generator that needs it.
The pure python equivalent listed in the docs uses separate
deques for each subiterator, but the actual C implementation
of itertools.tee() only has one internal deque that is shared
by all of the sub-iterators.
More information about the Python-list