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

Serhiy Storchaka storchaka at gmail.com
Sun Apr 15 13:35:51 EDT 2018


15.04.18 19:52, Tim Peters пише:
> No, I don't ;-)  If I have to catch StopIteration myself now, then I
> want the entire "white True:" loop in the "try" block.  Setting up
> try/except machinery anew on each iteration would add significant
> overhead; doing it just once per derived generator wouldn't.

This overhead is around 10% of the time for calling `next(it)`. It may 
be less than 1-2% of the whole step of mytee iteration.

I have ideas about implementing zero-overhead try/except, but I have 
doubts that it is worth. The benefit seems too small.



More information about the Python-ideas mailing list