My 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?
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.