[Feature Request] key_equal
, copy_key
, zero_key
in dict is slower than direct assignment if key type is primitive
#9519
Labels
Hi, I noticed an unoptimized situation that
key_equal
,copy_key
,zero_key
in dict are slower than direct assignment if key type is primitive. The root cause is if key_type doesn't contain meminfo, thenkey_equal
will rollback to usingmemcmp
, which is pretty slow compared to directlythis_key == an_integer
. Other two functions will rollback to usingmemcpy
, which is also slow.numba/numba/cext/dictobject.c
Line 448 in a060559
numba/numba/cext/dictobject.c
Line 434 in a060559
I think we can do more things in this intrinsic function, which includes generation of corresponding functions (i.e.,
key_equal
,copy_key
,zero_key
) for primitive types. I have already tested this in an internal use-case, this optimization can boost performance at least 5%~10% if using numba typed.dict heavily (i.e., lots of dict lookup, insert operations)numba/numba/typed/dictobject.py
Line 264 in a060559
The text was updated successfully, but these errors were encountered: