[ty] Introduce fast path for protocol non-assignability#23952
Merged
charliermarsh merged 2 commits intomainfrom Mar 14, 2026
Merged
[ty] Introduce fast path for protocol non-assignability#23952charliermarsh merged 2 commits intomainfrom
charliermarsh merged 2 commits intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132. |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
Merging this PR will improve performance by 47.6%
Performance Changes
Comparing Footnotes
|
b202085 to
99f3d7d
Compare
99f3d7d to
0893325
Compare
carljm
approved these changes
Mar 14, 2026
| /// Protocol compatibility can only succeed if every required member is present. Check that | ||
| /// necessary condition up front so we can avoid expensive per-member type comparisons and | ||
| /// generic protocol solving when the actual type is plainly missing a member. | ||
| fn has_all_protocol_members_defined( |
Contributor
There was a problem hiding this comment.
Minor nit: should this be a free function in protocol_class.rs (or a method on ProtocolInstanceType?) rather than an associated function on TypeRelationChecker?
carljm
added a commit
that referenced
this pull request
Mar 16, 2026
* main: (131 commits) [ty] Fixup examples in `invalid-key` docs (#23968) [ty] Fix compiler warning about unused variable (#23967) [ty] Sync vendored typeshed stubs (#23963) Add a `.git-blame-ignore-revs` file (#23959) Revert "[ty] Completely remove the `NoReturn` shortcut optimization" (#23955) [ty] Completely remove the `NoReturn` shortcut optimization (#23378) [ty] Introduce fast path for protocol non-assignability (#23952) Bump typing conformance suite SHA (#23951) Minor followup to severity display - use preview function in server instead of checking preview disabled directly (#23950) Document editor features for markdown code formatting (#23924) [ty] Add `with_recursion_guard()` helpers to `relation.rs` (#23945) [ty] Remove `check_optional_method_pair` methods (#23947) [ty] Remove unused `CycleDetector::try_visit` method (#23944) [ty] Ensure TypedDict subscripts for unknown keys return Unknown (#23926) [ty] Fix variance of frozen dataclass-transform models (#23931) Display output severity in preview (#23845) Revert "[`ruff`] use `bitcode` instead of `bincode`" (#23935) Fix shell injection via `shell=True` in subprocess calls (#23894) [ty] Refactor `relation.rs` to store state on a struct rather than passing around 7 arguments every time we recurse (#23837) Don't return code actions for non-Python documents (#23905) ...
Member
|
Oh this is clever, nicely done! |
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
This PR adds a fast path to first verify that every required protocol member is definitely present.
Closes astral-sh/ty#3026.