fork(1) download
  1. import time
  2. import numpy
  3. import random
  4.  
  5. n = 30000
  6. m = 1
  7.  
  8.  
  9. t = time.time()
  10. for i in range(10**m):
  11. list((numpy.random.rand(n) * 10).astype(int))
  12. print("numpy way took %.3f seconds" % (time.time() - t))
  13.  
  14. t = time.time()
  15. for i in range(10**m):
  16. [random.randint(0,10) for _ in range(n)]
  17. print("randint way took %.3f seconds" % (time.time() - t))
Success #stdin #stdout 0.39s 29848KB
stdin
Standard input is empty
stdout
numpy way took 0.028 seconds
randint way took 0.279 seconds