Provide explicit function signatures for numba
stestoll opened this issue · 2 comments
On my system, numba is crashing Python when @njit
-decorated functions are called. The problem disappears when explicit function signatures are provided to @njit
. Should we provides these?
Like Julia, numba can take advantage of multiple dispatch. This means I can njit
function without specifying the type and it will work on several different types.
@njit
def myfunc(inp):
return inp
print(myfunc(10)) # -> 10
print(myfunc('10')) # -> '10'
But once you specify a signature you can only use types of that signature.
@njit(''i8(i8)')
def myfunc(inp):
return inp
print(myfunc(10)) # -> 10
print(myfunc('10')) # -> TypeError: No matching definition for argument type(s) unicode_type
This is useful because it allows njit
functions to be more dynamic. If I specify signatures, then I would need to specify all possible signatures if I want to maintain this functionality. In your specific case, using multiple signatures may not fix the crashing problem, so it may not even be worth it.
This issue appears to have been resolved with numba/numba#8852