为什么Java虚拟机中没有GIL?为什么Python需要这么糟糕? [英] Why is there no GIL in the Java Virtual Machine? Why does Python need one so bad?

查看:374
本文介绍了为什么Java虚拟机中没有GIL?为什么Python需要这么糟糕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以提供一些见解,了解Java虚拟机的根本不同之处在于它可以很好地实现线程而无需全局解释器锁(GIL),而Python则需要这样的恶意。

I'm hoping someone can provide some insight as to what's fundamentally different about the Java Virtual Machine that allows it to implement threads nicely without the need for a Global Interpreter Lock (GIL), while Python necessitates such an evil.

推荐答案

Python(该语言)不需要GIL(这就是为什么它可以完美地在JVM [Jython]上实现的原因。 NET [IronPython],这些实现多线程自由)。 CPython(流行的实现)总是使用GIL来简化编码(尤其是垃圾收集机制的编码)以及非线程安全的C编码库的集成(过去常常有大量的; - )。

Python (the language) doesn't need a GIL (which is why it can perfectly be implemented on JVM [Jython] and .NET [IronPython], and those implementations multithread freely). CPython (the popular implementation) has always used a GIL for ease of coding (esp. the coding of the garbage collection mechanisms) and of integration of non-thread-safe C-coded libraries (there used to be a ton of those around;-).

Unladen Swallow 项目,以及其他雄心勃勃的目标,计划一个GIL- Python的免费虚拟机 - 引用该网站,此外,我们打算删除GIL并修复Python中多线程的状态。我们相信这可以通过实现更复杂的GC系统来实现,例如IBM的Recycler (Bacon等,2001)。

The Unladen Swallow project, among other ambitious goals, does plan a GIL-free virtual machine for Python -- to quote that site, "In addition, we intend to remove the GIL and fix the state of multithreading in Python. We believe this is possible through the implementation of a more sophisticated GC system, something like IBM's Recycler (Bacon et al, 2001)."

这篇关于为什么Java虚拟机中没有GIL?为什么Python需要这么糟糕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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