Take this simple code:
import numba as nb
import numpy as np
@nb.njit
def make_dict():
d = {(1, 0, 3): np.ones(10)}
A = (np.ones(10))
d[(1, 2, 3)] = A
return d
B = make_dict()
print(repr(B))
This gives:
DictType[UniTuple(int64 x 3),array(float64, 1d, C)]<iv=None>({(1, 0, 3): [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.], (1, 2, 3): [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]})
What does <iv=None> mean and is it something to worry about?
Oyibo
October 1, 2023, 11:04am
2
In Numba dicts or lists have an initial_value
property. Numba uses it to make code faster by knowing what’s in the dictionary from the beginning, allowing it to optimize the code better.
https://numba.readthedocs.io/en/stable/reference/pysupported.html#feature-dict-initial-value
import numba
@numba.njit
def foo():
d = {'A':1, 'B':2}
d['B'] = 99
return d
d = foo()
print(d)
print(numba.typeof(d))
# {A: 1, B: 99}
# DictType[unicode_type,int64]<iv={'A': 1, 'B': 2}>
2 Likes