GH-89987: Shrink the BINARY_SUBSCR
caches
#103022
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BINARY_SUBSCR
has 3 cache entries that are only used byBINARY_SUBSCR_GETITEM
(a type version and a function version). However, we don't really need to store all of this information per call-site... we can just keep the function version on the type (next to the cached method) and clear the cached method whenever the type is modified.Besides the savings in code size, this has a couple of other minor benefits:
BINARY_SUBSCR_GETITEM
site can work with any heap type defining__getitem__
, provided it's already been cached at least once somewhere.Performance is neutral.