[Python-Dev] PEP 492 quibble and request (original) (raw)
Paul Moore p.f.moore at gmail.com
Thu Apr 30 11:02:17 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 492 quibble and request
- Next message (by thread): [Python-Dev] PEP 492 quibble and request
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 30 April 2015 at 02:52, Nick Coghlan <ncoghlan at gmail.com> wrote:
This request isn't about understanding the implementation details, it's about understanding what Python users will gain from the PEP without needing to understand the implementation details.
For that, I'd like to see some not-completely-trivial example code in (or at least linked from) the PEP written using: * trollius (no "yield from", Python 2 compatible, akin to Twisted's inlineDeferred's) * asyncio/tulip ("yield from", Python 3.3+ compatible) * PEP 492 (async/await, Python 3.5+ only) The intent of PEP 492, like PEP 380 and PEP 342 before it, is "make asynchronous programming in Python easier". I think it will actually succeed in that goal, but I don't think it currently does an especially job of explaining that to folks that aren't both already deeply invested in the explicitly asynchronous programming model and thoroughly aware of the fact that most of us need asynchronous programming to look as much like synchronous programming as possible in order for it to fit our brains.
I agree 100% on this. As things stand, it feels as though asyncio feels frighteningly complex for anyone who isn't deeply involved with it (it certainly does to me). The current PEP feels to an outsider as if it is solving problems that are specialist and to the average (non-asyncio) programmer add language complexity with no real benefit.
It's not specific to PEP 492, but what I would like to see is:
More tutorial level examples of how to use asyncio. Specifically not examples of how to write web services, or how to do async web requests in your existing async program. Instead, how to integrate asyncio into generally non-async code. For example, looking at pip, I see a few places where I can anticipate asyncio might be useful - the link-chasing code, the package download code, and the code to run setup.py in a subprocess, seem like places where we could do stuff in an async manner (it's not a big enough deal that we've ever used threads, so I doubt we'd want to use asyncio either in practice, but they are certainly the types of code I see as benefitting from async).
Following on from this, how do I isolate async code from the rest of my program (i.e. I don't want to have to rewrite my whole program around an event loop just to run a bunch of background programs in parallel)?
Clarification on the roles of async/await vs yield from/generator.send. Are they both useful, and if so in what contexts (ignoring "if you want to support Python 3.4" compatibility cases)? How should a programmer choose which is appropriate?
A much better explanation of when any of the async constructs are appropriate at all. The name "asyncio" implies IO, and all of the examples further tend to imply "sockets". So the immediate impression is that only socket programmers and people writing network protocols should care.
Of course, if asyncio and the PEP are only really relevant to network protocols, then my impressions are actually correct and I should drop out of the discussion. But if that's the case, it seems like a lot of language change for a relatively specialist use case.
- Previous message (by thread): [Python-Dev] PEP 492 quibble and request
- Next message (by thread): [Python-Dev] PEP 492 quibble and request
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]