-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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 鈥淪ign up for GitHub鈥, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-124153: Implement PyType_GetBaseByToken() and Py_tp_token slot
#124163
Conversation
|
I'll check this and PoC version again. |
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.
Looks great, thank you!
I have just one style suggestion. But if you'd like to keep it we can merge the PR as it is.
Objects/typeobject.c
Outdated
| return -1; | ||
| } | ||
|
|
||
| if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) { |
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.
When I observed a good performance, the line had a typo (missing a NOT), though check_base_by_token() was unused during a PGO test. The telco got slower by 5-10% once I corrected, which was actually fixed by one of the following:
-
Use
if-elsestatement -
Replace
_PyType_HasFeature()with the publicPyType_HasFeature(), not with ineffective(type->tp_flags & Py_TPFLAGS_HEAPTYPE)
They are not used in PyType_GetBaseByToken().
This chains the branches in PyType_GetBaseByToken() as well, which is effective when MSVC is in better condition on PGO.
|
I think I've finished. When checking a type without a result, this may be a bit slower than the draft PR, not trained well for now. |


PyType_GetBaseByTokenfunction withPy_tp_tokenslot聽#124153馃摎 Documentation preview 馃摎: https://cpython-previews--124163.org.readthedocs.build/