r/Python • • Sep 09 '22

Discussion Async Python is not faster

https://calpaterson.com/async-python-is-not-faster.html
0 Upvotes

47 comments sorted by

View all comments

21

u/rouille Sep 09 '22

I think this misses the main appeal of async. It's not about speed but about the programming model. Async makes it much easier to work with and compose concurrency compared to the thread based model. Just the fact that you can cancel tasks makes it trivial to do proper timeouts, which nobody gets right in sync applications, for example.

It also allows things like structured concurrency.

-5

u/benefit_of_mrkite Sep 09 '22

It’s also worth mentioning that not all operations make sense for async - file system ops are are blocking.

The main purpose of asynchronous in python is working around the GIL

4

u/alkasm github.com/alkasm Sep 09 '22 edited Sep 09 '22

The main purpose of asynchronous in python is working around the GIL

No, it isn't. The GIL isn't mentioned at all in any of the async PEPs:

Threading on a single core (a-la Python's GIL) isn't fundamentally that different from async code; with async, the programmer decides when to context switch (via await), whereas in threading, the OS decides when to context switch.

The primary motivation of async programming in Python is that it is an extremely useful, modern paradigm for concurrency, allowing for better event-driven processing than threads do. From PEP 492:

We believe that the changes proposed here will help keep Python relevant and competitive in a quickly growing area of asynchronous programming, as many other languages have adopted, or are planning to adopt, similar features

-2

u/benefit_of_mrkite Sep 10 '22

Go read the old python mailer.

I’m old.