Re:Parallelising Python with Threading and Multiprocessing
by andreasvc on Saturday May 03, 2014 @04:46PM
(#7692295)
It would be interesting if you could give some arguments for your positions. Why is STM not the way? Why, if IronPython is as good as you say it is, doesn't it see greater adoption or why don't other implementations use its strategies for removing the GIL? Wikipedia says that IronPython scores worse on PyStone benchmarks compared to CPython, and it's likely that this is a consequence of IronPython's fine-grained locking which is required in the absence of a GIL.
As for interfacing with C, like I said, Cython really makes this a lot easier than the approaches you mention. You mention IronPython as not having a GIL, but then IronPython doesn't allow easy interfacing with C code, e.g., it's not compatible with numpy ...
you have several choices for C integration in Python. SWIG, which is now generally considered a huge mess, hand-wrapping, which is a tedious pain, and dlopen/dlsym methods that talk to the C api direectly (which requires something like GCCXML to handle type recognition for complicated APIs).
I don't think PyPy's approach to transactional memory is the right direction either.
In short: multithreading on multicore machines is how you write performant software in industry. The hardware is designed for, the compilers are designed for it, and if you don't take advantage of it, you're just wasting machines.
Now people could argue that multiprocessing addresses it, but it's just message passing between different process spaces, which while a wonderful and powerful tool, is ultimately just more cumbersome (hey, I used to write big MPI/OpenMP apps that did both models at the same time).
Anyway, the ultimate existence proof is that IronPython was both faster serially and in parallel, without the GIL, than CPython. So basically we know it's possible. The Python developers have no will, inclination, or ability to make it so,.