Python 中的 GIL
最近面试问到了 GIL,虽然以前知道,但是非常的生疏了,现在再系统的学习一下。
这里会包含如下的内容:
- GIL 是什么?
- 如何写出更加高效代码?
- 如何绕过 GIL 的限制?
GIL 是什么?
在说 GIL 之前,我们先看看 Python 的不同实现: CPython, Pypy, Jython 等等。
而 GIL 只是在 CPython 和 PyPy 中有,其他的实现中并没有这种限制。
先挖坑了,最近准备找实习,没太多时间研究了。抽时间补上吧。
参考
- http://www.dabeaz.com/GIL/gilvis/index.html
- http://www.dabeaz.com/python/UnderstandingGIL.pdf
- https://opensource.com/article/17/4/grok-gil
- https://callhub.io/understanding-python-gil/
- http://jessenoller.com/blog/2009/02/01/python-threads-and-the-global-interpreter-lock
- http://zhuoqiang.me/python-thread-gil-and-ctypes.html