Currently BINARY_SUBSCR_DICT just calls PyDict_GetItemWithError.
We should make use of dk_version for zero cost lookups on dictionaries.
Main problem I can think of:
Dictionaries used as a cache might frequently add and delete keys, so this would perform badly as deoptimizations would be frequent.
Solution: a modified function called PyDict_GetItemWithErrorCached. That takes in our _PyBinarySubscrCache and modifies that. On failure, instead of deoptimizing, just update the cache and go through the usual PyDict_GetItemWithError path. This isn't any slower than going through the unspecialized BINARY_SUBSCR and PyObject_GetItem routine.
Fidget-Spinner commentedSep 26, 2022
•
edited
Currently
BINARY_SUBSCR_DICT
just callsPyDict_GetItemWithError
.We should make use of
dk_version
for zero cost lookups on dictionaries.Main problem I can think of:
Dictionaries used as a cache might frequently add and delete keys, so this would perform badly as deoptimizations would be frequent.
Solution: a modified function called
PyDict_GetItemWithErrorCached
. That takes in our_PyBinarySubscrCache
and modifies that. On failure, instead of deoptimizing, just update the cache and go through the usualPyDict_GetItemWithError
path. This isn't any slower than going through the unspecializedBINARY_SUBSCR
andPyObject_GetItem
routine.I'm going to work on this at the sprint.
CC @markshannon and @iritkatriel.
The text was updated successfully, but these errors were encountered: