[Python-Dev] Tricky way of of creating a generator via a comprehension expression

Serhiy Storchaka storchaka at gmail.com
Thu Nov 23 09:45:03 EST 2017


23.11.17 16:30, Paul Moore пише:
> Ok, cool. My main point still applies though - has anyone confirmed
> why a function scope was considered necessary at the time of the
> original implementation, but it's apparently not now? I'm pretty sure
> it was a deliberate choice, not an accident.

The implementation with an intermediate one-time function is just 
simpler. The one of purposes of Python 3 was simplifying the 
implementation, even at the cost of some performance penalty. I'm pretty 
sure the corner case with "yield" was just missed.



More information about the Python-Dev mailing list