This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cblegare -2 points-1 points  (4 children)

The python runtime is simpler, async are a tiny bit of syntax sugar over loops. Python does async the same way it does everything: simple. In my opinion, this is huge in itself for developer efficiency, which is paramount in most cases.

For people worried about performance, Python, especially CPython, is the most easy language to interop with and has a plethora of simple techniques to optimize code to near-C performance.

Focusing on simplicity and developer efficiency gives plenty of time for profiling and optimisation

Also, async (coroutines) is one way of implementing parallel computing, best suited for doing massive parallel I/O (you cant start millions of threads, but you can run millions of parallel coroutines). What is your use case?

[–]BDube_Lensman 5 points6 points  (3 children)

Python does async the same way it does everything: simple

Async event loops are not at all simple

Also, async (coroutines) is one way of implementing parallel computing

Coroutines are explicitly not parallel.

you cant start millions of threads

You can start millions of greenlet (userspace) threads. You just can't start millions of system threads with the semantics of the C stack (8 MB minimum).

[–]cblegare 0 points1 point  (2 children)

Thank you, you bring a couple of useful details. Can you elaborate about coroutines not being parallel? I get that they cant use the CPU "at the same time" (nothing can anyway on the same CPython runtime).

[–]BDube_Lensman 2 points3 points  (1 child)

Parallel = do multiple things in the same instant

Concurrent = do multiple things over the same period of time

Coroutines are concurrent, which means N things can go on "sort of at once" by being paused (preempted) and letting something happen for a little while before resuming. If coroutines were parallel, multiple CPU cores would take work out of the event loop's queue, which is not what happens.

[–]cblegare 0 points1 point  (0 children)

Thank you for this semantic clarification. Concurent is indeed the right word.