[Python-Dev] PEP 380 (yield from a subgenerator) comments

Antoine Pitrou solipsis at pitrou.net
Sat Mar 21 15:18:03 CET 2009


Nick Coghlan <ncoghlan <at> gmail.com> writes:
> 
> Whether or not different people will find code using "yield from"
> difficult to understand or not will have more to do with their grasp of
> the concepts of cooperative multitasking in general more so than the
> underlying trickery involved in allowing truly nested generators.

I don't agree. Cooperative multitasking looks quite orthogonal to me to the
complexity brought by this new statement. You can perfectly well "grasp the
concepts of cooperative multitasking" without finding the semantics of this new
statement easy to understand and remember. Hiding so many special cases behind a
one-line statement does not help, IMO. And providing a commented version of the
expansion does not really help either: it does not make the expansion easier to
remember and replay in the case you have to debug something involving such a
"yield from" statement.

(remember, by the way, that a third-party package like greenlets already
provides cooperative multitasking without any syntax addition, and that
libraries like Twisted already have their own generator-based solution for
cooperative multitasking, which AFAIR no one demonstrated would be improved by
the new statement. I'm not sure where the urgency is, and I don't see any
compelling use case.)




More information about the Python-Dev mailing list