[Python-Dev] PEP 492: No new syntax is required
Paul Sokolovsky
pmiscml at gmail.com
Tue Apr 28 21:24:22 CEST 2015
Hello,
On Mon, 27 Apr 2015 08:48:49 +0100
Mark Shannon <mark at hotpy.org> wrote:
>
>
> On 27/04/15 00:13, Guido van Rossum wrote:
> > But new syntax is the whole point of the PEP. I want to be able to
> > *syntactically* tell where the suspension points are in coroutines.
> Doesn't "yield from" already do that?
>
> > Currently this means looking for yield [from]; PEP 492 just adds
> > looking for await and async [for|with]. Making await() a function
> > defeats the purpose because now aliasing can hide its presence, and
> > we're back in the land of gevent or stackless (where *anything* can
> > potentially suspend the current task). I don't want to live in that
> > land.
>
> I don't think I was clear enough. I said that "await" *is* a
> function, not that is should be disguised as one.
Yes, you said, but it is not. I guess other folks left figuring that
out for yourself, and it's worthy exercise. Hint: await appears to
translate to GET_AWAITABLE and YIELD_FROM opcodes. If your next reply
is "I told you so", then you again miss that "await" is a special
Python language construct (effectively, operator), while the fact that
its implemented as GET_AWAITABLE and YIELD_FROM opcodes in CPython is
only CPython's implementation detail, CPython being just one (random)
Python language implementation.
> Reading the code,
> "GetAwaitableIter" would be a better name for that element of the
> implementation. It is a straightforward non-blocking function.
Based on all this passage, my guess is that you miss difference
between C and Python functions. On C level, there're only functions
used to implement everything (C doesn't offer anything else). But on
Python level, there're larger variety: functions, methods, special forms
(a term with a bow to Scheme - it's a function which you can't implement
in terms of other functions and which may have behavior they can't
have). "await" is a special form. The fact that it's implemented by a C
function (or not exactly, as pointed above) is just CPython's
implementation detail. Arguing that "await" should be something based
on what you saw in C code is putting it all backwards.
--
Best regards,
Paul mailto:pmiscml at gmail.com
More information about the Python-Dev
mailing list