fork download
  1. from time import time
  2. from sys import getsizeof
  3.  
  4. a,b,c = 0,0,0
  5. D = {a:0, b:0, c:0}
  6. N = 1000_000
  7. stt = time()
  8. for i in range(N): a,b,c = i, i+1, i+2
  9. print(time()-stt)
  10.  
  11. stt = time()
  12. for i in range(N): D[a], D[b], D[c] = i, i+1, i+2
  13. print(time()-stt)
  14.  
  15. print(getsizeof(a), getsizeof(b), getsizeof(c))
  16. print(getsizeof(D[a]), getsizeof(D[b]), getsizeof(D[c]))
  17. print(getsizeof(D))
  18.  
Success #stdin #stdout 0.43s 9204KB
stdin
Standard input is empty
stdout
0.16907310485839844
0.2373521327972412
28 28 28
28 28 28
240