Python GIL确实是每个解释器吗? [英] Is the Python GIL really per interpreter?

查看:133
本文介绍了Python GIL确实是每个解释器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常看到人们在谈论GIL是基于Python解释器的(即使在stackoverflow上也是如此).

I often see people talking that the GIL is per Python Interpreter (even here on stackoverflow).

但是我在源代码中看到的似乎是GIL是一个全局变量,因此每个python进程中的所有解释器都有一个GIL.我知道他们这样做是因为没有像lua或TCL那样传递解释器对象,只是一开始设计得不好.而且线程本地存储似乎不便于python家伙使用.

But what I see in the source code it seems to be that the GIL is a global variable and therefore there is one GIL for all Interpreters in each python process. I know they did this because there is no interpreter object passed around like lua or TCL does, it was just not designed well in the beginning. And thread local storage seems to be not portable for the python guys to use.

这是正确的吗?我在这里的项目中使用了2.4版本.

Is this correct? I had a short look at the 2.4 version I'm using in a project here.

在以后的版本中,尤其是在3.0版本中,这有变化吗?

Had this changed in later versions, especially in 3.0?

推荐答案

GIL实际上是每个进程的,而不是每个解释器的.在3.x中未更改.

The GIL is indeed per-process, not per-interpreter. This is unchanged in 3.x.

这篇关于Python GIL确实是每个解释器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆