gh-74690: Micro-optimise typing._get_protocol_attrs#103152
Conversation
carljm
left a comment
There was a problem hiding this comment.
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?
hauntsaninja
left a comment
There was a problem hiding this comment.
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 👍 |
…03152) Improve performance of `isinstance()` checks against runtime-checkable protocols
This PR is a bunch of micro-optimisations for
typing._get_protocol_attrsthat together have a significant impact on the speed ofisinstancechecks 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.