Skip to content

[ty] Deduplicate retained scope inference types#25805

Draft
charliermarsh wants to merge 1 commit into
mainfrom
charlie/deduplicate-scope-inference-types
Draft

[ty] Deduplicate retained scope inference types#25805
charliermarsh wants to merge 1 commit into
mainfrom
charlie/deduplicate-scope-inference-types

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

Scope inference retains a type for every expression in the scope. Many expressions share the same type, but the existing frozen map stores a complete Type value in every entry.

This adds a frozen map representation that stores each distinct value once and maps sorted keys to compact value indices. Scope inference uses the new representation when freezing its expression types, and cycle normalization rebuilds the table so normalized values are deduplicated again.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jun 10, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 92.23%. The percentage of expected errors that received a diagnostic held steady at 87.42%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 35.38MB 35.29MB -0.25% (90.01kB) ⬇️
trio 87.75MB 87.23MB -0.59% (534.12kB) ⬇️
sphinx 207.56MB 205.71MB -0.89% (1.85MB) ⬇️
prefect 564.13MB 556.27MB -1.39% (7.86MB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
infer_scope_types_impl 788.72kB 698.71kB -11.41% (90.01kB) ⬇️

trio

Name Old New Diff Outcome
infer_scope_types_impl 3.78MB 3.25MB -13.81% (534.12kB) ⬇️

sphinx

Name Old New Diff Outcome
infer_scope_types_impl 12.55MB 10.69MB -14.76% (1.85MB) ⬇️

prefect

Name Old New Diff Outcome
infer_scope_types_impl 47.64MB 39.79MB -16.50% (7.86MB) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant