Repository navigation
Skip the symbol table scan for missing methods - #22345
Merged
Merged
Conversation
TypeInfo.get_method scanned every name in each MRO entry when a method was absent. On colour, native sampling attributed 21% of the baseline profile to this lookup. The semantic analyzer inserts the unnumbered "name-redefinition" before any numbered redefinitions. Check for that key first. When it exists, select the same lexicographically last definition as before. This keeps the fallback that dataclass InitVars need. Both binaries checked the same source trees cold. The baseline was b286c11. input median before -> after paired wall reduction self 6.227 s -> 6.169 s 0.84% torch 3.251 s -> 3.278 s -0.11% pandas 24.372 s -> 23.622 s 2.82% colour 38.643 s -> 29.050 s 24.69% jax 29.032 s -> 27.883 s 3.39% zulip 14.505 s -> 14.154 s 2.19% The torch interval spans zero (-0.75% to +0.47%). Each pair ran both Clang 18 release binaries on the same CPU set, with an empty mypy cache. The order alternated over 12 pairs for self, 14 for torch 2.1.0, and eight per project from mypy_primer 9889850. The last column averages within-pair wall time ratios. All pairs produced byte-identical diagnostics. The checker, fine-grained incremental, and dependency suites passed (9,134 tests). An independent multifile mypyc build reduced colour wall time by 26.01% across six pairs (95% interval 25.66% to 26.67%). Its self result was inconclusive (0.20%, interval -0.64% to 1.15%). A common import path and common typeshed files gave a 0.60% self improvement across 14 pairs with the single-unit build.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
JukkaL
approved these changes
Nov 2, 2026
JukkaL
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fix, this is a nice win.
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.
Authored by Codex, here's its description below.
Note that its baseline doesn't include #22270 so it probably overstates the win a little