It's not perfect and yes the core design was inspired from c#. But the reason it's so complex is multifaceted:

- Unlike nodejs, asyncio's event loop is configurable.

- It has actual thread and multi process support. (2/n)
- Backward compatibility with old style non native coroutines.

- It exposes a lot more internal machineries compared to nodejs, which can be both a curse and a blessing.

- The docs were overly technical and targeted towards framework developers, not casual end users. (3/n)
But things have changed a lot and many of the complaints are no longer valid anymore.

- .get_even_loop() will get you a deterministic thread bound event loop

- .get_running_loop() will get you the current running loop

- Context vars can solve many synchronization issues (4/n)
- .run() takes care of event loop creation and some of the boilerplate cleanup jobs.

- The docs now have a proper delineation between high level and low level APIs.

- Uvloop, written in Cython, based on libuv, is a lot faster than the reference event loop implementation. (5/n)
- Task cancellation is a beast of a problem and PEPs are still being written to make this easier.

- Trio and Curio's structured concurrency is driving some of the future design decisions of asyncio. (6/n)
It's lot to grasp but also pretty amazing to see how a 30 years old community driven language can evolve so quickly. So much hard work behind each of them and so many clever ideas. 🔥 (n/n)
You can follow @rednafi.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: