Hello,
I have a simple function that I would like to njit in numba that takes a list of strings as the argument and returns a tuple of int and bool. The problem is with the function argument. When I do the following:
@njit(types.Tuple((types.int32, types.boolean))(types.List(types.unicode_type,True)))
def func(items: list[str]) -> tuple[int, bool]:
return len(items), 'apple' in items
print(func(["apple", "orange", "banana"])) #(3, True)
I get the warning:
NumbaPendingDeprecationWarning:
Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'lst' of function 'in_seq.<locals>.seq_contains_impl'.
For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types
def in_seq(context, builder, sig, args):
def seq_contains_impl(lst, value):
^
warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))
However when I change it to use typed.List
below:
from numba import njit, types, typed
@njit(types.Tuple((types.int32, types.boolean))(typed.List(types.unicode_type)))
def func(items: list[str]) -> tuple[int, bool]:
return len(items), 'apple' in items
print(func(["apple", "orange", "banana"]))
I get:
KeyError: 'Can only index numba types with slices with no start or stop, got 0.'
What should I do in this situation?
My numba version is 0.58.0 and the Python version is Python 3.9.17 and am using a Mac Book Pro with an M1 chip