-
Notifications
You must be signed in to change notification settings - Fork 7
Python multiprocessing and threading
Louis Maddox edited this page Feb 7, 2021
·
1 revision
In my experience, Python multiprocessing is more efficient, and you should use
mp.Process
not mp.Pool
(Pool only seems to assign 4 cores, whereas Process
can use all).
Process is most efficient when all cores are assigned a single Python process,
which does not have to share it with others. You see that when using
more Process
es than there are cores on your machine (multiprocessing.cpu_count()
)
the speed decreases (the time to compute the same thing increases).
Pool is still a decent approach compared to sequential code (which will only use 1 core)