-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
gh-74690: Micro-optimise typing._get_protocol_attrs
#103152
gh-74690: Micro-optimise typing._get_protocol_attrs
#103152
Conversation
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 fine to me.
Given @hauntsaninja 's feedback in #103141 , are you planning to land a single news entry for this and that one and #103034 that summarizes the changes and the overall perf impact?
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.
Hooray, thanks for working on this!
Yeah, I'll try to rework the NEWS entry in #103034 to summarise the changes made in the performance-related PRs as well as that PR 👍 |
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!
…03152) Improve performance of `isinstance()` checks against runtime-checkable protocols
This PR is a bunch of micro-optimisations for
typing._get_protocol_attrs
that together have a significant impact on the speed ofisinstance
checks against runtime-checkable protocols.Benchmark:
Results on dfc4c95:
Results with this PR:
I'm once again skipping NEWS, since #103034 will counteract the boost to performance here, so the overall impact on performance for runtime-checkable protocols in 3.12 is still TBD.