【发布时间】:2021-09-29 22:47:00
【问题描述】:
我正在尝试通过使用 numba 的重载 (docs here) 在 numba jitted 函数中使用外部定义的函数,但是当我运行它时 Python 内核会死掉。这是我要重现的最小示例:
from numpy.polynomial.legendre import leggauss as lg # My externally defined function
import numba as nb
from numba.extending import overload
@overload(lg)
def implimentlg(n):
if not isinstance(n, (int, nb.types.Integer, nb.int32)):
raise nb.errors.TypingError("must be int")
def impli(n):
return lg(n)
return impli
@nb.jit(nopython=True)
def tmp():
return lg(15)
tmp()
我猜我的问题与我在 implimentlg 函数中的输入有关,但没有堆栈跟踪,我不知所措。
【问题讨论】: