On Wed, Apr 29, 2015 at 2:26 PM, Paul Moore <p.f....@gmail.com> wrote:
> On 29 April 2015 at 18:43, Jim J. Jewett <jimj...@gmail.com> wrote:>> So? PEP 492 never says what coroutines *are* in a way that explains>> why it matters that they are different from generators.
...
> Looking at the Wikipedia article on coroutines, I see an example of> how a producer/consumer process might be written with coroutines:>> var q := new queue>> coroutine produce> loop> while q is not full> create some new items> add the items to q> yield to consume>> coroutine consume> loop> while q is not empty> remove some items from q> use the items> yield to produce>> (To start everything off, you'd just run "produce").>> I can't even see how to relate that to PEP 429 syntax. I'm not allowed> to use "yield", so should I use "await consume" in produce (and vice> versa)?
I think so ... but the fact that nothing is actually coming via the
await channel makes it awkward.
I also worry that it would end up with an infinite stack depth, unless
the await were actually replaced with some sort of framework-specific
scheduling primitive, or one of them were rewritten differently to
ensure it returned to the other instead of calling it anew.
I suspect the real problem is that the PEP is really only concerned
with a very specific subtype of coroutine, and these don't quite fit.
(Though it could be done by somehow making them both await on the
queue status, instead of on each other.)
-jJ
_______________________________________________
Python-Dev mailing list
Pyth...@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.com