Advertisement
DigitalMag

Numba benchmark: list as param (500x vs numpy, without - 4x)

Jan 31st, 2020
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import time
  2. from numba import jit
  3. import numpy
  4.  
  5. test_iter = 1000000
  6.  
  7. ##@jit(nopython=True)
  8. def jit_calc(a,l,it):
  9.  
  10.     s = 0
  11.     for i in range(it):
  12.         s += a
  13.         l[i]=s
  14.     return l
  15.  
  16. def main():
  17.  
  18.     print 'start'
  19.  
  20. ##    ls = numpy.array(range(test_iter))
  21.     ls = range(test_iter)
  22.  
  23.  
  24.     d = jit_calc(1, ls, 1)
  25.  
  26.  
  27.  
  28.     t = time.time()
  29.  
  30.     l = len(jit_calc(10, ls ,test_iter))
  31.  
  32.     print time.time() - t
  33.  
  34.     print l
  35.  
  36. if __name__ == '__main__':
  37.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement