Antoine Pitrou wrote:
There seems to be a misunderstanding as to how generators
are used in Twisted. There isn't a global "trampoline" to schedule generators
around. Instead, generators are wrapped with a decorator (*) which collects each
yielded value (it's a Deferred object) and attaches to it a callback which
resumes (using send()) the execution of the generator whenever the Deferred
finally gets its value.

This sounds like an architecture that was developed to
work around the lack of anything like yield-from in the
language.

You can't expect to improve something like that by
stuffing yield-from into the existing framework, because
the point of yield-from is to render the framework
itself unnecessary. To take full advantage of it, you
need to step back and re-design the whole thing in
a different way.

In the case of Twisted, I expect the new design would
look a lot like my generator scheduling example.

--
Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to