【发布时间】:2017-11-05 23:14:44
【问题描述】:
对装饰器进行更好的动态控制的最佳方法是什么 - 从numba.cuda.jit、numba.jit 和无(纯 python)中选择。 [请注意一个项目可以有10s或100s的功能,所以这应该很容易应用于所有功能]
这是来自 numba 网站的示例。
import numba as nb
import numpy as np
# global control of this --> @nb.jit or @nb.cuda.jit or none
# some functions with @nb.jit or cuda.jit with kwargs like (nopython=True, **other_kwargs)
def sum2d(arr):
M, N = arr.shape
result = 0.0
for i in range(M):
for j in range(N):
result += arr[i,j]
return result
a = np.arange(81).reshape(9,9)
sum2d(a)
【问题讨论】:
标签: python performance numba