[Python-Dev] Importance of "async" keyword
Nick Coghlan
ncoghlan at gmail.com
Fri Jun 26 12:46:15 CEST 2015
On 26 Jun 2015 05:15, "Andrew Svetlov" <andrew.svetlov at gmail.com> wrote:
>
> > Another issue that bothers me, is code reuse. Independent from whether
the
> > 'async def' makes sense or not, it would not allow us to reuse asyncio
> > functions as if they were normal functions and vice versa (if I
understood
> > that correctly). So, we would have to implement things twice for the
asyncio
> > world and the classic world. To me, it would be important to use one
> > function in either world where it suits me better. I am uncertain if
that
> > makes sense but right now it does to me.
>
>
> Yes, you cannot call async function from synchronous code. There are
> two worlds: classic and async.
Exactly, the sync/async split is inherent in the problem domain. Nobody
really likes this consequence of explicitly asynchronous programming
models, and this is a good article on why it's annoying:
http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/
However, it's also one of those cases like binary floating point: there are
good underlying reasons things are the way they are, but truly coming to
grips with them can take a long time, so in the meantime time it's
necessary to just accept it as "just one of those things" (like learning
negative or complex numbers for the first time). For explicitly
asynchronous programming, Glyph's post at
https://glyph.twistedmatrix.com/2014/02/unyielding.html is a decent
starting point on that journey.
Cheers,
Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150626/ce5cf42c/attachment.html>
More information about the Python-Dev
mailing list