python dict 构造函数性能比较
from time import time t1 = time() {i: "%d" % i for i in range(5000)} t2 = time() print(t2-t1) t1 = time() dict((i, "%d" % i) for i in range(5000)) t2 = time() print(t2-t1) assert dict((i, 1) for i in range(10)) == {i: 1 for i in range(10)}
0.0015797615051269531 要快些
0.0018689632415771484