3 ms·
Python's multiprocessing library (http://docs.python.org/library/multiprocessing.html http://docs.python.org/library/multiprocessing.html) provides a similar in
by scott_s 17y ago
Python's multiprocessing library (http://docs.python.org/library/multiprocessing.html http://docs.python.org/library/multiprocessing.html) provides a similar interface that one would expect from a multithreaded library. For example,
from multiprocessing import Pool
p = Pool(5)
def f(x):
return x*x
p.map(f, [1,2,3])
I do not have direct experience with the library, but from what I've seen, the code you would write is not significantly different from the code you'd write using a decent multithreading interface.
- fauigerzigerk 17y agoMultiple processes cannot share regular in memory data structures. That makes the multiprocessing library unsuitable for a growing class of applications. However, unladen swallow aims to remove the GIL, so there's still hope for Python.
- scott_s 17y agoThere is an API for both communicating data explicitly, and for allocating shared memory data structures which can be shared implicitly.
- fauigerzigerk 17y agoI know. That's why I said "regular in-memory data structures".