thanks, I understand. The filling of the dictionary can be done in jitted code, when the source is an array, list, tuple, anything that can be passed into a jitted function. Python dictionaries cannot be passed to a jitted function, so filling the typed.Dict from a python dict can only be done in a normal function (so without the decorator as you found out).
The 2 seconds you mention are the result of having to compile the typed.Dict for your types. The cost will not be 2 seconds every time you run the function, only the first time. Look at the example below:
import time
import numba as nb
# @nb.jit(nopython=True, cache=True)
def getNumbaDictFromDict(myDict):
returnDict = nb.typed.Dict.empty(
key_type=nb.types.unicode_type,
value_type=nb.types.float64, )
for runner in range(len(list(myDict))):
returnDict[list(myDict.keys())[runner]] = myDict[list(myDict.keys())[runner]]
return returnDict
myDict = {'a': 14., 'b': 15., 'c': 16.}
# running first time
my_time = time.time()
abc = getNumbaDictFromDict(myDict)
print('time:', time.time() - my_time)
# running a second time
my_time = time.time()
abc = getNumbaDictFromDict(myDict)
print('time:', time.time() - my_time)
time: 2.0478579998016357
time: 0.0002455711364746094