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

Jim J. Jewett jimjjewett at gmail.com
Fri May 1 20:26:28 CEST 2015


On Thu, Apr 30, 2015 at 3:32 PM, Guido van Rossum <guido at python.org> wrote:

(me:)
>> A badly worded attempt to say
>> Normal generator:  yield (as opposed to return) means
>> that the function isn't done, and there may be more
>> things to return later.

>> but an asynchronous (PEP492) coroutine is primarily saying:

>>      "This might take a while, go ahead and do something else
>> meanwhile."

(Yuri:) Correct.

(Guido:)> Actually that's not even wrong. When using generators as
coroutines, PEP 342
> style, "yield" means "I am blocked waiting for a result that the I/O
> multiplexer is eventually going to produce".

So does this mean that yield should NOT be used just to yield control
if a task isn't blocked?  (e.g., if its next step is likely to be
long, or low priority.)  Or even that it wouldn't be considered a
co-routine in the python sense?

If this is really just about avoiding busy-wait on network IO, then
coroutine is way too broad a term, and I'm uncomfortable restricting a
new keyword (async or await) to what is essentially a Domain Specific
Language.

-jJ


More information about the Python-Dev mailing list