Skip to content

Skip the symbol table scan for missing methods - #22345

Merged
JukkaL merged 1 commit into
python:masterfrom
hauntsaninja:symb
Nov 2, 2026
Merged

JukkaL merged 1 commit into
python:masterfrom
hauntsaninja:symb

Conversation

@hauntsaninja

@hauntsaninja hauntsaninja commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Authored by Codex, here's its description below.

Note that its baseline doesn't include #22270 so it probably overstates the win a little

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 b286c11c49ef.

    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.

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.
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, this is a nice win.

@JukkaL
JukkaL merged commit 75d170a into python:master Nov 2, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants