Python: Numba doesn't recognize None when using signature

Viewed 120

Numba is not recognizing the None argument when using signatures and I would like to use them since I noticed the code is faster when implemented. Here is the example without the signature that is working fine:

@njit(cache=True)
def funct(a, b=None):
    if b is not None:
        res = a+b
    else:
        res = a+1
    return res

here is the example that gives an error:

@njit(float64(float64, optional(float)), cache=True)
def funct(a, b=None):
    if b is not None:
        res = a+b
    else:
        res = a+1
    return res

and the error is:

No implementation of function Function(<built-in function add>) found for signature:
 >>> add(float64, OptionalType(<class 'float'>) i.e. the type '<class 'float'> or None')

How can I solve this? Thanks a lot!

0 Answers
Related