I was re-reading this just to realize how far #Python& #39;s asyncio has come since 2016. https://abs.twimg.com/emoji/v2/... draggable="false" alt="đź§µ" title="Thread" aria-label="Emoji: Thread">(1/n) https://lucumr.pocoo.org/2016/10/30/i-dont-understand-asyncio/">https://lucumr.pocoo.org/2016/10/3...
It& #39;s not perfect and yes the core design was inspired from c#. But the reason it& #39;s so complex is multifaceted:

- Unlike nodejs, asyncio& #39;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& #39;s structured concurrency is driving some of the future design decisions of asyncio. (6/n)
It& #39;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. https://abs.twimg.com/emoji/v2/... draggable="false" alt="🔥" title="Feuer" aria-label="Emoji: Feuer"> (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: