摘要:
原文地址:http://zhuoqiang.me/python-thread-gil-and-ctypes.htmlGIL 与 Python 线程的纠葛GIL 是什么东西?它对我们的 python 程序会产生什么样的影响?我们先来看一个问题。运行下面这段 python 程序,CPU 占用率是多少?# 请勿在工作中模仿,危险:)def dead_loop(): while True: passdead_loop()答案是什么呢,占用 100% CPU?那是单核!还得是没有超线程的古董 CPU。在我的双核 CPU 上,这个死循环只会吃掉我一个核的工作负荷,也就是只占用 50% ... 阅读全文