Live data from Hacker News

Python has had async for 10 years – why isn't it more popular?

tonybaloney.github.io

41–50 of 305 posts

Re: Python has had async for 10 years – why isn't it more popular?

#41

Python's async is very difficult to use and debug. It seems to get stuck randomly, read like race conditions. And Python cannot work around this nicely with their lambdas only permitting a single expression in their body. Not worth the trouble. Shell pipelines are way easier to use. Or simply waiting —no pun intended— for the synchronous to finish.

> lambdas only permitting a single expression

Use a tuple, maybe walrus, and return the last item[-1].

Re: Python has had async for 10 years – why isn't it more popular?

#42

The author gets close to what I think the root problem is, but doesn't call it out. The truth is that in python, async was too little, too late. By the time it was introduced, most people who actually needed to do lots of io concurrently had their own workarounds (forking, etc) and people who didn't actually need it had found out how to get by without it (multiprocessing etc). Meanwhile, go showed us what good green…

green thread have pitfalls too, like this: https://news.ycombinator.com/item?id=39008026

Re: Python has had async for 10 years – why isn't it more popular?

#43
The two api issue basically means async is not backwards compatible. You can't just squeeze some async into an existing code base, You'd need new functions, libraries etc. You'd basically need to rewrite the entire codebase in async to see an ounce of perf improvements.

Re: Python has had async for 10 years – why isn't it more popular?

#44

With the newest Python, I can use no-gil, so my threads automatically use multiple cores. With asyncio, even under no-gil, unless I use a base layer that offers parallelism, I am stuck to a single core by default, which doesn't make any sense in a multicore world. In contrast, with Rust's async, there is no such limitation. The traditional argument against the above assertion has been that asyncio is good for I/O wor…

[deleted]

Re: Python has had async for 10 years – why isn't it more popular?

#45
post #6

async, parallelism, concurrency, why not all three? JS, the canonical async (at least today) language, has had neither parallelism nor concurrency primitives for a good decade or so after its inception. I personally blame low async adoption in Python on 1) general reduction in its popularity vs Typescript+node, which is driven by the desire to have a single stack on the frontend and backend, not by bad or good async…

> async, parallelism, concurrency, why not all three? async is a concurrency mechanism.

async enables a concurrency potential, nothing more

That is, if you use external stuff and can delegate work to them, then async is concurrent (async io for instance)

But if you do not, then async is regular code with extra steps

Re: Python has had async for 10 years – why isn't it more popular?

#46
I used to keep plugging Unyielding [1] vs. What Color Is Your Function [2] as the right matrix to view these issues within. But then Notes on structured concurrency [3] was written and I just point to that these days.

But, to sum it all up for those who want to talk here, there are several ways to look at concurrency but only one that matters. Is my program correct? How long will it take to make my program correct? Structured concurrency makes that clear(er) in the syntax of the language. Unstructured concurrency requires that you hold all the code in your head.

[1]: https://glyph.twistedmatrix.com/2014/02/unyielding.html

[2]: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...

[3]: https://vorpus.org/blog/notes-on-structured-concurrency-or-g...

Re: Python has had async for 10 years – why isn't it more popular?

#47
post #37

I haven't read the article yet, but I do have something to contribute: several years ago I was ay PyCon and saw a talk in which someone mentioned async. I was interested and wanted to learn to use it. But I found there was no documentation at all! The syntax was briefly described, but not the semantics. I realized, years later, that the (non-)documentation was directed at people who were already familiar with the fea…

this was my initial experience with python async as well (which i now use heavily)

the documentation is directed at people who want coroutines and futures, and know what that means. if you don't know what coroutines and futures are, the python docs aren't going to help you. the documentation isn't going to guide anybody into using the async features who aren't already seeking them out. and maybe that's intentional, but it's not going to grow adoption of the async features.

Re: Python has had async for 10 years – why isn't it more popular?

#48
the two issues I have with async is are:

1) its infectious. You need to wrap everything in async or nothing.

2) it has non-obvious program flow.

Even though it is faster in a lot of cases (I had a benchmark off for a web/socket server for multi-threaded vs async with a colleague, and the async was faster.) for me it is a shit to force into a class.

The thing I like about threads is that the flow of data is there and laid out neatly _per thread_, where as to me, async feels like surprise goto. async feels like it accepts a request, and then will at some point at the future either trigger more async, or crap out mixing loads of state from different requests all over the place.

To me it feels like a knotted wool bundle, where as threaded/multi-process feels like a freshly wound bobbin.

Now, this is all viiiiiibes man, so its subjective.

Re: Python has had async for 10 years – why isn't it more popular?

#49
post #21

I've had no real issues with async, although I primarily use libraries like aiohttp and aiosqlite and even write my own helpers ( https://github.com/rcarmo/aioazstorage is a good example). The vast majority of the Python code I wrote in the last 5-6 years uses asyncio, and most of the complaints I see about it (hard to debug, getting stuck, etc.) were -- at least in my case -- because there were some other libraries…

I share your experience

asyncio is easier than threads or multiprocess: less locking issue, easier to run small chunks of code in // (easier to await something than to create a thread that run some method)

Post reply on HN