numba可以加速python代码,特别是numpy计算与for循环的操作,以下demo如果将装饰器注释掉,会发现代码运行慢很多很多。
from numba import jit import time @jit(nopython=True) def test(): sum = 0 for i in range(1000000000): sum = sum + i pass print(sum) start = time.time() test() end = time.time() print(end-start)