[Python-Dev] async/await in Python; v2 (original) (raw)
Wolfgang Langner tds333+pydev at gmail.com
Thu Apr 23 18:58:15 CEST 2015
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 23, 2015 at 6:22 PM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
Wolfgang,
On 2015-04-23 12:12 PM, Wolfgang Langner wrote: On Thu, Apr 23, 2015 at 5:32 PM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
Hi Wolfgang,
On 2015-04-23 8:27 AM, Wolfgang Langner wrote: On Thu, Apr 23, 2015 at 12:35 PM, Paul Sokolovsky <pmiscml at gmail.com> wrote:
Hello,
On Thu, 23 Apr 2015 12🔞51 +0300 Andrew Svetlov <andrew.svetlov at gmail.com> wrote:
[] 3.
async with and async for Bead idea, we clutter the language even more and it is one more thing every newbie could do wrong. for x in y: result = await f() is enough, every 'async' framework lived without it over years.
async for i in iterable: pass is not equal for for fut in iterable: i = yield from fut But people who used Twisted all their life don't know that! They just know that "async for" is not needed and bad.
I don't think it is bad nor not needed, but the syntax is not beautiful and for the 90% not doing async stuff irritating and one more thing to learn and do right/wrong. There is no way to do things wrong in PEP 492. An object either has aiter or it will be rejected by async for. An object either has aenter or it will be rejected by async with. Don't mean it can be done wrong on execution or syntax level. I mean for a beginner it is not as easy an more and some will try async in some places, yes they will get an error. But there is a new possibility to get such errors if async is there for with and for statements. And the next beginner will then implement aiter instead of iter because he/she don't get it. Sorry, Wolfgang, but I don't get your argument. Beginners shouldn't just randomly try to use statements. There is a documentation for that. Plus we can make exception messages better.
Had to coach a lot of new users to Python and some to async stuff in twisted. And what beginners not should do don't care them. ;-) They will do strange stuff and go other way's than you expected. I only like to make it as easy as possible for them. Nothing more. Less keywords, less ways to do something, best only one way to do it.
Don't get me wrong, I like the PEP it is well written and covers a lot of areas about async programming. I know Python must improve in this area and has a lot of potential. But don't hesitate, give the people time to try it and mature it. If all this should be in 3.5 it is to early.
Also we can avoid the async keyword completely and do the same as for generators. If there is an await, it is a coroutine. IDE's can detect generators and must only be expanded to detect coroutines.
Function with yield -> return a generator with await -> return a coroutine
Move async for and async with to another PEP and handle it later or with a different syntax using the new await keyword.
Only one new keyword, good improvement for async programming.
Sorry still don't like the word async in a language and sprinkle it every where. And still have the feeling if we provide async for loop we next must provide async like generator expresions or list comprehensions or ... never ends ;-)
The only downside with await converting a function to a coroutine is, it is not explicit marked. But if we care about this, whats about generators and yield ?
-- bye by Wolfgang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150423/7eb7bf42/attachment.html>
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]