Haskell vs. Python Streaming Model

Maybe someone there with the right interests who will know how to answer this. The main question is: what are the differences between the multiprocessing module in Python and parallelism in Haskell. For example: threads created in Python mapped to OS threads? If so, what if there are more threads than cores? Are they multiplexed into OS threads? Who plans these flows? Thanks for all the info: documentation / ideas that were appreciated.

+6
source share
2 answers

Unlike Python (see Eli answer ), the Haskell streaming model is completely different. You have the difference between concurrency (multiple threads handling different aspects of the program) and parallelism (multiple threads just to speed up the calculations). Both are handled by lightweight streams controlled by Haskell RTS. In the second case, you can use primitives such as pseq and par , which hint that the runtime performs calculations in another thread, if this gives an advantage. Runtime automatically makes this decision.

+7
source

The Python multiprocessing module has nothing to do with threads. It tries to provide an API similar to threading (which calls threads), with processes under it.

Python threads map to OS threads, and if you create more threads than kernels, the same thing happens as if you were doing it in C ( pthreads , Win API threads, etc.) - the OS manipulates threads between cores.

There's a lot of information on the Internet about Python threads, just Google.

+6
source

Source: https://habr.com/ru/post/892065/


All Articles