A public relations problem
A public relations problem
Posted Jul 10, 2015 14:49 UTC (Fri) by Kwi (subscriber, #59584)Parent article: A better story for multi-core Python
Calling the GIL a public relations problem is exactly right. It's more a PR problem than a technical problem, anyway.
If you want concurrency in your Python application, you have the following options:
- Just use threads (if you're I/O-bound). The GIL is only a problem if you're CPU-bound.
- Use message passing instead of shared memory for communication. Besides removing a bunch of race condition worries, it enables you to use Python concurrency solutions like multiprocessing that avoid the GIL. (The proposed subinterpreter support is just one more of these solutions.)
- Implement your performance critical code in a C module, allowing you to avoid the GIL - and harness the improved performance of C.
- Implement your performance critical code in Cython, for the same benefits as C, with a Python-like syntax.
- Use Jython.
- Use IronPython.
- Use PyPy. In fact, if you're CPU-bound, why are you not using this already?
"If you want your code to run faster, you should probably just use PyPy." — Guido van Rossum
Would it be easier for everybody if we could all just use threads and not worry about the GIL? Yes. But performance is rarely easy - not in Python, nor in any language.
