| Store | Cart

Re: [Python-Dev] PEP 492: What is the real goal?

From: Jim J. Jewett <jimj...@gmail.com>
Thu, 30 Apr 2015 13:24:27 -0400
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

Recent Messages in this Thread
Jim J. Jewett Apr 29, 2015 05:43 pm
Paul Moore Apr 29, 2015 06:26 pm
Yury Selivanov Apr 29, 2015 06:42 pm
Paul Moore Apr 29, 2015 07:19 pm
Yury Selivanov Apr 29, 2015 07:42 pm
Skip Montanaro Apr 29, 2015 08:14 pm
Nathaniel Smith Apr 29, 2015 08:19 pm
Guido van Rossum Apr 29, 2015 08:30 pm
Greg Ewing Apr 30, 2015 06:53 am
Paul Sokolovsky Apr 30, 2015 07:58 am
Paul Moore Apr 29, 2015 10:02 pm
Greg Ewing Apr 30, 2015 06:35 am
Arnaud Delobelle Apr 30, 2015 08:50 am
Oscar Benjamin May 05, 2015 04:01 pm
Yury Selivanov May 05, 2015 04:48 pm
Guido van Rossum May 05, 2015 07:24 pm
Oscar Benjamin May 06, 2015 09:20 am
Paul Sokolovsky Apr 29, 2015 09:06 pm
Greg Ewing Apr 30, 2015 12:08 pm
Paul Moore Apr 30, 2015 06:52 pm
Greg Ewing Apr 30, 2015 05:39 am
Paul Moore Apr 30, 2015 08:17 am
Jim J. Jewett Apr 30, 2015 05:24 pm
Guido van Rossum Apr 30, 2015 05:55 pm
Guido van Rossum Apr 28, 2015 09:49 pm
Yury Selivanov Apr 28, 2015 11:26 pm
Ethan Furman Apr 28, 2015 11:55 pm
Guido van Rossum Apr 29, 2015 12:04 am
Ethan Furman Apr 29, 2015 05:18 am
Greg Ewing Apr 29, 2015 09:12 am
Yury Selivanov Apr 29, 2015 05:00 am
Greg Ewing Apr 29, 2015 09:13 am
Yury Selivanov Apr 29, 2015 02:01 pm
Greg Ewing Apr 29, 2015 10:46 pm
Yury Selivanov Apr 29, 2015 10:58 pm
Greg Ewing Apr 29, 2015 09:12 am
Yury Selivanov Apr 29, 2015 02:16 pm
Greg Apr 29, 2015 03:59 am
Yury Selivanov Apr 29, 2015 04:10 am
Greg Ewing Apr 29, 2015 09:13 am
Yury Selivanov Apr 29, 2015 02:18 pm
Greg Ewing Apr 29, 2015 09:12 am
Yury Selivanov Apr 29, 2015 02:29 pm
Messages in this thread