[Python-Dev] Await and Async keywords

Aymeric Fromherz aymeric.fromherz at ens.fr
Fri Mar 24 11:31:48 EDT 2017


Thanks for the quick answer! I'll have a look at this PEP.

Cheers

On 24/03/2017 16:17, Jelle Zijlstra wrote:
> 
> 
> 2017-03-24 3:57 GMT-07:00 Aymeric Fromherz <aymeric.fromherz at ens.fr
> <mailto:aymeric.fromherz at ens.fr>>:
> 
>     Hi,
> 
>     I'm currently looking into how Python3 is parsed, and I'm wondering why
>     await and async aren't considered as keywords? Are there programs
>     actually using await and async as variable names? Is there another
>     behaviour where it is interesting to use async for something different?
> 
> They are not keywords to prevent breaking backwards compatibility, but
> they will be full keywords in 3.7. async/await was introduced in 3.5,
> and Python generally avoids introducing backwards-incompatible in minor
> versions. Usually, that's done with __future__ imports; if I recall
> correctly, when "with" statements were introduced (making "with" a
> keyword), Python first released one or two versions where you had to do
> "from __future__ import with_statement" to use them, and then this flag
> was turned on by default. For async/await, instead the parser was hacked
> to recognize "async def" as a special token, and to add special parsing
> rules within "async def" function to recognize other uses of async and
> await. However, this is temporary and async and await will be full
> keywords in Python 3.7.
> See https://www.python.org/dev/peps/pep-0492/#transition-plan.
> 
> And yes, real code uses async and await as identifiers. asyncio itself
> had a function called asyncio.async() (now renamed to ensure_future()).
> Making async and await full keywords would have immediately broken any
> such code for people who were upgrading to Python 3.5.
> 
>  
> 
>     Cheers,
>     Aymeric
>     _______________________________________________
>     Python-Dev mailing list
>     Python-Dev at python.org <mailto:Python-Dev at python.org>
>     https://mail.python.org/mailman/listinfo/python-dev
>     <https://mail.python.org/mailman/listinfo/python-dev>
>     Unsubscribe:
>     https://mail.python.org/mailman/options/python-dev/jelle.zijlstra%40gmail.com
>     <https://mail.python.org/mailman/options/python-dev/jelle.zijlstra%40gmail.com>
> 
> 


More information about the Python-Dev mailing list