[Python-Dev] PEP 492 quibble and request

Paul Sokolovsky pmiscml at gmail.com
Thu Apr 30 02:56:03 CEST 2015


Hello,

On Wed, 29 Apr 2015 20:33:09 -0400
Yury Selivanov <yselivanov.ml at gmail.com> wrote:

> Hi Ethan,
> 
> On 2015-04-29 8:21 PM, Ethan Furman wrote:
> >  From the PEP:
> >
> >> Why not a __future__ import
> >>
> >> __future__ imports are inconvenient and easy to forget to add.
> > That is a horrible rationale for not using an import.  By that
> > logic we should have everything in built-ins.  ;)
> >
> >
> >> Working example
> >> ...
> > The working example only uses async def and await, not async with
> > nor async for nor __aenter__, etc., etc.
> >
> > Could you put in a more complete example -- maybe a basic chat room
> > with both server and client -- that demonstrated more of the new
> > possibilities?
> 
> Andrew Svetlov has implemented some new features in his
> aiomysql driver:
> 
> https://github.com/aio-libs/aiomysql/blob/await/tests/test_async_iter.py
> 
> I don't want to cite it in the PEP because it's not complete
> yet, and some idioms (like 'async with') aren't used to their
> full potential.
> 
> >
> > Having gone through the PEP again, I am still no closer to
> > understanding what happens here:
> >
> >    data = await reader.read(8192)
> >
> > What does the flow of control look like at the interpreter level?
> 
> 'await' is semantically equivalent to 'yield from' in this line.
> 
> To really understand all implementation details of this line
> you need to read PEP 3156 and experiment with asyncio. There
> is no easier way, unfortunately.  I can't add a super detailed
> explanation how event loops can be implemented in PEP 492,
> that's not in its scope.
> 
> The good news is that to use asyncio on a daily basis you
> don't need to know all details, as you don't need to know
> how 'ceval.c' works and how 'setTimeout' is implemented in
> JavaScript.

+1

But if you really want, you can. The likely reason for that though
would be desire to develop "yield from" for an alternative Python
implementation. You can take inspiration from a diagram I drew while I
implemented "yield from" for MicroPython:
https://dl.dropboxusercontent.com/u/44884329/yield-from.pdf


-- 
Best regards,
 Paul                          mailto:pmiscml at gmail.com


More information about the Python-Dev mailing list