XiangqianMa / GitTalk

my gittalk.
0 stars 0 forks source link

Python全局解释器锁(GIL) | MXQ #31

Open XiangqianMa opened 4 years ago

XiangqianMa commented 4 years ago

http://activepony.com/python/python-quan-ju-jie-shi-qi-suo-gil/

Python全局解释器锁(GIL)以如下代码为例: 123def CountDown(n): while n > 0: n -= 1 首先测试其在单线程情况下的运行时长,在我的机器上,上述代码的运行时间为6s左右。 下面测试上述代码的多线程版本的运行时间: 12345678910from threading import Threadn = 100000000t1 = T