[Python-ideas] Make asyncio.get_event_loop a builtin
Mark E. Haase
mehaase at gmail.com
Fri May 25 14:07:11 EDT 2018
asyncio.coroutine and async def are slightly different—not synonyms. The
former defines a generator function and the latter defines a coroutine
function. Generators and coroutines are very similar in Python (they share
lots of code in the CPython implementation) but coroutines are preferred
for async programming. Furthermore, yield from (suspend a generator) and
await (suspend a coroutine) are also similar but not synonyms.
It is surprising that Python's async syntax isn't tightly bound to its
built-in implementation of asynchronous I/O. This was a shrewd decision
that—as others have pointed out—permits a variety of event loop
implementations. The downside—as you point out—is that there is no built-in
function that can drive an async function.
On Thu, May 24, 2018 at 8:42 PM, Ken Hilton <kenlhilton at gmail.com> wrote:
> On Tue May 22 22:08:40 (-0400), Chris Barker wrote:
> > while asyncio is in the standard library, it is not intended to be THE
> async event loop implementation
> I'm surprised this is true - with dedicated syntax like async def/await,
> it's still not THE async event loop implementation? As far as I know,
> "async def" is a shorthand for
> and "await" is short for "yield from".
> Ken Hilton;
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas