[ty] Materialize only substituted typevars during specialization#23725
Merged
charliermarsh merged 3 commits intomainfrom Mar 5, 2026
Merged
[ty] Materialize only substituted typevars during specialization#23725charliermarsh merged 3 commits intomainfrom
charliermarsh merged 3 commits intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅ |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
trio
sphinx
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
type-assertion-failure |
35 | 0 | 77 |
invalid-argument-type |
10 | 19 | 20 |
unused-type-ignore-comment |
4 | 11 | 0 |
unresolved-attribute |
0 | 11 | 2 |
invalid-return-type |
1 | 0 | 7 |
no-matching-overload |
0 | 7 | 0 |
invalid-assignment |
0 | 3 | 2 |
not-iterable |
0 | 4 | 0 |
unsupported-operator |
0 | 2 | 0 |
| Total | 50 | 57 | 108 |
Merging this PR will improve performance by 6.02%
Performance Changes
Comparing Footnotes
|
Member
Author
|
The ecosystem changes here look pretty good, so gonna spend some time understanding the change. |
eb12da2 to
e2a211a
Compare
e2a211a to
867b50f
Compare
ibraheemdev
approved these changes
Mar 5, 2026
Member
ibraheemdev
left a comment
There was a problem hiding this comment.
Haven't looked through the ecosystem report, but the code changes look good to me.
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.
Summary
See astral-sh/ty#2955 (comment) for a comprehensive write-up of the underlying issue.
Here's a Claude-generated example:
On main, the second pass materializes every gradual type, so
Anyonbwas turned intoobject. Now, only the types that come from substitutingTgets materialized, so the explicitAnyonbis left alone.IIUC, this is a bit worse in the contravariant case (again, with Claude's help):
Closes astral-sh/ty#2955.