Hacker News new | past | comments | ask | show | jobs | submit login

> easy-to-use concurrency paradigm

Well it has queues and threads already.

Its just that asyncio for socket handling at least (in the testing that I did) is about 5% faster. (one asyncio socket "server" vs ten threads [with a number of ways to monitor for new connections])

I always assumed that people wanted asyncio because they look at javascript and thought "hey I want GOTOs cosplaying as a fun paradigm"




GOTO cosplaying should go away with structured concurrency (via TaskGroup) being adopted in 3.11, as pioneered by Trio.

Check out anyio if you want to use them now.


TaskGroup in asyncio has been promised at least as far back as Python 3.8 [1]. They're still not in the draft "What's new in python 3.11" [2] and searching the web didn't return any official statements. I believe they're planned but don't believe they'll arrive any time soon.

If you want to use structured concurrency now, IMO the best bet is to use Trio directly. Reading posts by the author makes it clear that every detail of the library had been extremely scrutinised, not just the API (e.g. see this long post on ctrl-C handling [3], or any number of long technical discussions on the issue tracker), so I think it's a better choice in any case.

[1] https://twitter.com/1st1/status/1041855365745455104

[2] https://docs.python.org/3.11/whatsnew/3.11.html

[3] https://vorpus.org/blog/control-c-handling-in-python-and-tri...


Anyio is probably a best bet to use TaskGroup IMO. You can use the trio backend if you want, after all.

But it's asyncio compatible, which makes it more future proof.


Hmm, we'll just have to disagree on that one.

Trio has the better API, so you might as well use that directly rather some other library that attempts to match it, even if it can/does use it under the hood. It reminds me of that xkcd about standards. It's also going to have to settle for the least common denominator to some extent even if it reimplements some parts itself (e.g. if one library implements serial ports but the other didn't, then it surely can't be in anyio). I also dispute that it's "more future proof", because you're still relying on anyio being maintained, and to me it seems to be the more obscure library.


The idea is that once task groups are implemented, you can switch back to asyncio, which as more chance than Trio to be supported.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: