我测试了四种情况.
1.
testList = list()
for i in range(1000000):
testList.append(i)
Run Code Online (Sandbox Code Playgroud)
2.
testList = list()
for i in range(1000000): testList.append(i)
Run Code Online (Sandbox Code Playgroud)
3.
testList = list()
newAppend = testList.append
for i in range(1000000): newAppend(i)
Run Code Online (Sandbox Code Playgroud)
4.
[i for i in range(1000000)]
Run Code Online (Sandbox Code Playgroud)
每次都是
1:0.09166
2:0.08299
3:0.05003
4:0.04594
为什么其他人比1快?
我能找到相关的关键词吗?
| 归档时间: |
|
| 查看次数: |
716 次 |
| 最近记录: |