Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from numba import autojit, jit, void, double, int_
- def doloop(X,Y,mm):
- for i in range(Y):
- xx = mm[:]
- x = 0
- for j in range(X):
- xx[x] = x
- x += 1
- return 1
- looper = autojit(doloop)
- if __name__ == '__main__':
- X = 1000
- Y = 10000000
- zz = np.random.random(X)
- looper(X, Y, zz)
- # zz = np.random.randint(0,9,X)
- # zz = [0 for i in range(X)] # ... much slower than np array
- # doloop(X,Y/10,zz)
- #
- # 10,000,000 takes 7.6 seconds with numba
- # 1,000,000 takes 166 seconds with python
- # gain = 210 times
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement