独立可执行文件中的 GIL
GIL in standalone executables
我不太确定 GIL 是如何实现的,但理论上,如果我使用 pyinstaller 将 python 脚本编译成 exe,它是否仍会实现 GIL?有什么方法可以绕过它吗?
如果您使用的是 CPython ("standard Python"),GIL 将在那里。 Pyinstaller 不编译,但 bundles the Python script, its dependencies, and the interpreter 在可执行文件中使用。因此,绕过 GIL 的标准方法适用:
- C 扩展和 Cython code may release the GIL while not manipulating interpreter state or Python objects, or calling Python/C API functions.
- 在 multiple processes 之间分配工作。
我不太确定 GIL 是如何实现的,但理论上,如果我使用 pyinstaller 将 python 脚本编译成 exe,它是否仍会实现 GIL?有什么方法可以绕过它吗?
如果您使用的是 CPython ("standard Python"),GIL 将在那里。 Pyinstaller 不编译,但 bundles the Python script, its dependencies, and the interpreter 在可执行文件中使用。因此,绕过 GIL 的标准方法适用:
- C 扩展和 Cython code may release the GIL while not manipulating interpreter state or Python objects, or calling Python/C API functions.
- 在 multiple processes 之间分配工作。