Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global Interpreter lock: Jython vs CPython

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?

like image 570
lpan Avatar asked May 18 '26 03:05

lpan


1 Answers

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

like image 88
zonk Avatar answered May 20 '26 19:05

zonk