gh-156250: Speed up inherited mapping assignment slot calls - #156258
Open
koxudaxi wants to merge 2 commits into
Open
gh-156250: Speed up inherited mapping assignment slot calls#156258koxudaxi wants to merge 2 commits into
koxudaxi wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
__setitem__and__delitem__share themp_ass_subscriptslot. If a Python subclass of a C type overrides only one of them, the inherited operation is still dispatched throughslot_mp_ass_subscript()and called through awrapper_descriptor.When lookup returns the expected unbound wrapper descriptor,
slot_mp_ass_subscript()now calls the wrapped C slot directly. Python overrides and other descriptors continue through the generic call path.Benchmark
Release builds on macOS 15.7.1 arm64, based on main at
b062727097e997bcb900e11503d3248daac903da. Results are medians from nine alternating-order samples after two warmups.This reduces the
collections.Counterassignment benchmark by 549.45 ms (38.34%).Tests
Tests cover asymmetric
dictsubclasses, inherited slice deletion on alistsubclass, and fallback for custom or incompatible descriptors. The targeted tests pass on regular and free-threaded debug builds.Fixes #156250