当涉及到Numba中的类型推断时,我肯定遗漏了一些东西。我写了这个小样本,似乎找不到为什么它在编译时无法推断类型。你可以通过尝试运行它来重现它: import numpy as np
@njit(["void(uint8[::1], int16)"]type of <class 'numba.core.ir.Unde
我试着用基本的例子来比较numba和纯python,我得到了奇怪的结果。这是numba示例:from numpy import arange# jit decorator tellsNumba to compile this function.
# The argument types will be inferred by Numba when function is call
我需要在布尔值数组中存储几个单元格。一开始我使用numpy,但是当数组开始占用大量内存时,我有了一个想法,将非零元素以元组作为键存储在字典中(因为它是hashable类型)。Numba不支持本地Python的dict(),所以我使用了numba.typed.Dict。:True}Numba无法正确推断字典键的类型并返回错误:
Compilation is fallin