1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/usr/bin/env python #-*- coding:utf-8 -*- import
time
start =
time.time()
for
i in
range ( 1000000 ):
a =
( 1 , 2 , 3 , 4 )
print
time.time() -
start
start =
time.time()
for
i in
range ( 1000000 ):
a =
[ 1 , 2 , 3 , 4 ]
print
time.time() -
start
|
如果要迭代一列数据,用tuple比list优。
0.107225894928 0.200721979141
结果可以看出,生成1000000数据产生的结果不一样。