Why is there no GIL in the Java Virtual Machine? Why does Python need one so bad?(为什么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 项目以及其他雄心勃勃的目标,计划 用于 Python 的无 GIL 虚拟机——引用该网站的话,此外,我们打算移除 GIL 并修复 Python 中的多线程状态.我们相信这可以通过实现更复杂的 GC 系统来实现,例如 IBM 的 Recycler (Bacon et al, 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 这么需要一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么Java虚拟机中没有GIL?为什么 Python 这么需要一个?


基础教程推荐
- 验证是否调用了所有 getter 方法 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01