I want to use a numba.typed.List
(going to call it List
) to pass into my function which is wrapped in njit
. However this List
should be created from an existing python list.
When I look at the documentation it seems the way you create a List
is to initialize it and then append elements to it. However this requires you to loop over an already existing list in python which seems inefficient for large lists.
For example:
from numba.typed import List
numba_list = List()
py_list = ["a", "b", "c"]
for e in py_list:
numba_list.append(e)
In [17]: numba_list[0]
Out[17]: 'a'
Is there a way to set a
List
to the values of a python list without explicitly looping over the python list ?
I am using numba.__version__
= '0.47.0'