zeros.py 348 B

12345678910111213141516171819202122
  1. from time import time
  2. import numpy as np
  3. import bcolz
  4. N = 2e8
  5. dtype = 'i4'
  6. t0 = time()
  7. a = np.zeros(N, dtype=dtype)
  8. print("Time numpy.zeros() --> %.4f" % (time() - t0))
  9. t0 = time()
  10. ac = bcolz.zeros(N, dtype=dtype)
  11. # ac = bcolz.carray(a)
  12. print("Time bcolz.zeros() --> %.4f" % (time() - t0))
  13. print("ac-->", repr(ac))
  14. #assert(np.all(a == ac))