2016-10-19 37 views

回答

5

只需運行一個測試:

>>> import timeit 
>>> min(timeit.repeat('a = b = c = d = 1', number=10000000)) 
0.4885740280151367 
>>> min(timeit.repeat('a = 1; b = 1; c = 1; d = 1', number=10000000)) 
0.6283371448516846 

還要注意:

>>> min(timeit.repeat('a, b, c, d = 1, 1, 1, 1', number=10000000)) 
0.4040501117706299 
相關問題