Maybe there's someone out there with the right interests that will know how to answer this. Basically the question is: What are the differences between the multiprocessing
module in Python, and the parallelism in Haskell. For instance: are threads created in Python mapped to OS threads? If so, what if there are more threads than cores? Are they multiplexed into the OS threads? Who schedules these threads? Thanks for all the info: documentation/insights greatly appreciated.
As opposed to Python (See Eli's answer), the threading model of Haskell is quite different. You have a difference between concurrency (multiple threads handling different aspects of the program) and parallelism (multiple threads just to speed up computation). Both are handled by lightweight threads managed by the Haskell RTS. In the second case, one can use primitives like pseq
and par
that hints the runtime to do the calculation in another thread, if this gives an advantage. The runtime automagically decides this.
The Python multiprocessing
module has nothing to do with threads. It tries to provide an API similar to threading
(which does expose threads) with processes underneath.
Python threads are mapped to OS threads, and if you create more threads than cores the exact same thing happens as if you'd do it in C (pthreads
, Win API threads, etc.) - the OS juggles the threads between cores.
There's a lot of information online about Python threads, just Google it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With