-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-93911: Specialize LOAD_ATTR
for custom __getattr__
and __getattribute__
#93988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
markshannon
merged 21 commits into
python:main
from
Fidget-Spinner:specialize_overridden
Aug 17, 2022
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2f483f5
Specialize LOAD_ATTR for custom __getattr__
Fidget-Spinner de5aab9
fix up comments
Fidget-Spinner a795602
📜🤖 Added by blurb_it.
blurb-it[bot] b170204
fix version tag issues
Fidget-Spinner b4df543
update specialization failure name
Fidget-Spinner cd81fa9
fix getattr bug
Fidget-Spinner a2b0121
Fix type size in test_sys
Fidget-Spinner b0caba5
Merge remote-tracking branch 'upstream/main' into specialize_overridden
Fidget-Spinner 2a931a8
Use Mark's suggestions
Fidget-Spinner dd89339
fix test_sys
Fidget-Spinner 40e363b
Merge remote-tracking branch 'upstream/main' into specialize_overridden
Fidget-Spinner db13262
address review
Fidget-Spinner 0185748
Merge remote-tracking branch 'upstream/main' into specialize_overridden
Fidget-Spinner cab77d8
revert rename
Fidget-Spinner 81adecb
remove unsued failures
Fidget-Spinner 6845656
Address code review
Fidget-Spinner 9412f97
Use Mark's code
Fidget-Spinner c6f8610
Clean up code a little
Fidget-Spinner d887293
Merge remote-tracking branch 'upstream/main' into specialize_overridden
Fidget-Spinner cb7d01e
Update pycore_opcode.h
Fidget-Spinner def326e
Address review, make things more restrictive
Fidget-Spinner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An assertion about which slot is present during specialisation was failing in one of the buildbots. Apparently there are cases where the other slot (which potentially calls
__getattr__
) still stuck around even with no__getattr__
. This may mean the slot had not been called yet (seems strange considering specialised code is supposed to be hot).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which assertion?
Does that mean the assertion is incorrect, or that this test was?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one https://github.com/python/cpython/pull/93988/files#diff-22e653d878778ca28317261f7826545288d02fd9980cf485d0329f28a34993f2R834.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly, that assert is wrong, in the sense that it's OK if
type->tp_getattro == _Py_slot_tp_getattr_hook
provided that there it would convert itself to_Py_slot_tp_getattro
.Having said that, it is probably easier to reason about if we assert
type->tp_getattro == _Py_slot_tp_getattro
, and the impact on performance of the extra test will be negligible.