[Python-Dev] Await and Async keywords
Jelle Zijlstra
jelle.zijlstra at gmail.com
Fri Mar 24 11:17:51 EDT 2017
More information about the Python-Dev mailing list
Fri Mar 24 11:17:51 EDT 2017
- Previous message (by thread): [Python-Dev] Await and Async keywords
- Next message (by thread): [Python-Dev] Await and Async keywords
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2017-03-24 3:57 GMT-07:00 Aymeric Fromherz <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 > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ > jelle.zijlstra%40gmail.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170324/658a0560/attachment.html>
- Previous message (by thread): [Python-Dev] Await and Async keywords
- Next message (by thread): [Python-Dev] Await and Async keywords
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list