Does Jython have the GIL?

2019-01-18 19:59发布

I was sure that it hasn't, but looking for a definite answer on the Interwebs left me in doubt. For example, I got a 2008 post which sort of looked like a joke at first glance but seemed to be serious at looking closer.

Edit: ... and turned out to be a joke after looking even closer. Sorry for the confusion. Actually the comments on that post answer my question, as Nikhil has pointed out correctly.

We realized that CPython is far ahead of us in this area, and that we are lacking in compatibility. After serious brainstorming (and a few glasses of wine), we decided that introducing a Global Interpreter Lock in Jython would solve the entire issue!

Now, what's the status here? The "differences" page on sourceforge doesn't mention the GIL at all. Is there any official source I have overlooked?

Note also that I'm aware of the ongoing discussion whether the GIL matters at all, but I don't care about that for the moment.

4条回答
家丑人穷心不美
2楼-- · 2019-01-18 20:34

No, it does not. It's a part of the VM implementation, not the language.

See also:

from __future__ import braces
查看更多
男人必须洒脱
3楼-- · 2019-01-18 20:36

The quote you found was indeed a joke, here is a demo of Jython's implementation of the GIL:

Jython 2.5.0 (trunk:6550M, Jul 20 2009, 08:40:15) 
[Java HotSpot(TM) Client VM (Apple Inc.)] on java1.5.0_19
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import GIL
  File "<stdin>", line 1
SyntaxError: Never going to happen!
>>> 
查看更多
Viruses.
4楼-- · 2019-01-18 20:48

Both Jython and IronPython "lack" the GIL, because it's an implementation detail of the underlying VM. There was a lot of information I've found sometime ago, now the only thing I could come up with is this.

Remember that the GIL is only a problem on multiprocessor enviroment only, and that it's unlikely to go away in the foreseable future from CPython.

查看更多
爷、活的狠高调
5楼-- · 2019-01-18 20:48

Google is making a Python implementation that is an modified cpython with performance improvements called unladen swallow. This will take care of removing the GIL. See: Unladen Swallow

查看更多
登录 后发表回答