5 ms·
And no multiprocessing is not a solution, as it does not allows to share memory between processes. You actually can. multiprocessing defines a few classes (e.g
by bkcooper 12y ago
And no multiprocessing is not a solution, as it does not allows to share memory between processes.
You actually can. multiprocessing defines a few classes (e.g. Array) that store their data in a mmap kept in the module. Data there will be visible to all processes, and you can even have a numpy array as a view to this data.
That said, my attempts at working with this recently have been pretty painful. multiprocessing tries, but at least in Python 2.7 does not succeed in abstracting away the differences between Unix forks and Windows spawns. This results in a lot of weird issues: things running differently in command line vs. console IPython vs. IPython notebook; the need to structure your code to avoid pickling errors; etc. This is probably the biggest portability issue I've encountered with Python thus far (using it mostly for scientific problems.)
I'm aware that there are solutions to some of these issues out there, but it's too bad that the standard library implementation has these issues.
- slantedview 12y agoThe mmap solution, along with various others, are ridiculous workarounds for folks dead set on jamming a square peg into a round, single-threaded hole. If a technology doesn't support something that you need, natively, don't rely on lame workarounds, use a more appropriate technology.