Reputation: 468
CPython
uses GIL
to prevent problems such as mutual exclusion. However, the consequence is that the interpreter is not able to take advantage of a multi-core CPU. I also learnt that Jython
does not require a GIL because its implementation is already thread-safe.
Does it mean that Jython is a superior implementation when it comes to concurrent programming and utilizing a multi-core CPU?
Upvotes: 3
Views: 567
Reputation: 167
Yes, Jython uses Java-Threads (even if you're using the threading modul of Python) and so it has no GIL. But this isn't the answer (otherwise it has to be 42, because the question is unclear :^) ). The better Question is, what criteria you have and if CPython or Jython would be better.
If you want real multithreadding, it's your thing. If you want to use Java and Python, use it. If you want fast execution times .... then are other languages maybe better (you can try to messure the time in a thread task in Python and the same code in Jython, but I guess even with GIL CPython would be faster).
Greets, Zonk
Upvotes: 1