Python requires GIL. But Jython & IronPython do not. What for?

Why can you run Jython and IronPython without having to use GIL, but Python (CPython) requires GIL?

+4
source share
2 answers

Parts of the interpreter are not thread safe, although mainly due to the fact that their use in streaming mode with the massive use of blocking slows down single-threaded. (source) . This is similar to CPython's garbage collector using reference counting (the JVM and CLR do not, and therefore it is not necessary to lock / free the reference count every time). But even if someone thought of an acceptable solution and implemented it, third-party libraries would still have the same problems.

Please note that extensions written in C can actually get rid of GIL: http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock

+8
source

My guess is because the C libraries on which CPython is built are not thread safe. While Jython and IronPython are created against Java and .Net respectively.

+2
source

All Articles