我只是想听听其他人对为什么这段特定代码在 Python 3.11 中运行速度可能比在 Python 3.10.6 中慢的想法。从这里交叉发布 。我是新来的 - 如果我做错了什么,请告诉我。
测试.py脚本:
import timeit
from random import random
def run():
for i in range(100):
j = random()
t = timeit.timeit(run, number=1000000)
print(t)
Run Code Online (Sandbox Code Playgroud)
命令:
(base) conda activate python_3_10_6
(python_3_10_6) python test.py
5.0430680999998
(python_3_10_6) conda activate python_3_11
(python_3_11) python test.py
5.801756700006081
Run Code Online (Sandbox Code Playgroud)