I have a python dictionary with keys being strings and values being lists of strings
myDict = {'key1': ['value1', 'value2'],
'key2': ['value3', 'value4']}
I would like to use this dictionary inside a numba jitted function. In the first step I try to create a Numba typed dictionary and use it within the function based on the codes and docs from the web
from numba import njit
from numba.core import types
from numba.typed import Dict
d = Dict.empty(
key_type=types.unicode_type,
value_type=types.ListType(types.unicode_type),
)
# The typed-dict can be used from the interpreter.
d['key1'] = np.asarray(['value1', 'value2'], dtype='U')
d['key2'] = np.asarray(['value3', 'value4'], dtype='U')
but this already results in a wonderful error
No implementation of function Function(<built-in function setitem>) found for signature:
>>> setitem(DictType[unicode_type,ListType[unicode_type]]<iv=None>, unicode_type, array([unichr x 1], 1d, C))
Also re-creating the dict by hand isn't an option, as the dict is pretty large. So I would need to transfer python dictionary to numba dictionary
I tried to reuse the solution provided here: https://numba.discourse.group/t/how-to-convert-a-non-numba-dictionary-to-a-nb-typed-dict/865 But here again - I don't provide the correct value_type as in my toy example from above