Advertisement
DigitalMag

Numba benchmark (create|return) [] (4x)

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