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 这么需要一个?
基础教程推荐
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- JPA惰性列表上的流 2022-01-01
