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 <kenlhil...@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
>
> @asyncio.coroutine
> def
>
> and "await" is short for "yield from".
>
> Sincerely,
> Ken Hilton;
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to