ruff
a2203732 - [ty] Cache protocol receiver binding (#27301)

Commit
10 days ago
[ty] Cache protocol receiver binding (#27301) ## Summary Protocol-member compatibility repeatedly specializes the same callable for the same runtime receiver and typing `Self`, rebuilding signatures and constraint sets on each structural comparison. - Add a private Salsa-tracked protocol receiver-binding cache keyed by the callable, receiver type, and `Self` type. - Route all four existing protocol compatibility binding sites through the cache, including protocol-to-protocol member comparisons. - Preserve distinct receiver and `Self` bindings and reuse `apply_self` when they are identical. This is independently useful on `main` and becomes even more relevant with #27267. ## Performance DateType on clean `main` and this PR, with 40 samples per version: | Version | Estimate | 95% confidence interval | | --- | ---: | ---: | | Baseline | 38.701 ms | 38.336–39.125 ms | | Protocol receiver cache with fixed-point recovery | 33.887 ms | 33.742–34.033 ms | The change is **12.4% faster**, with non-overlapping confidence intervals. ## Test plan - Add a minimized mdtest for a generic protocol whose receiver-specific method and classmethod produce a recursive receiver-binding query; verify that the expected return-type diagnostic is reported instead of a Salsa panic. - Reproduce the exact ecosystem-analyzer configuration for DateType, scipy-stubs, and trio, and verify that all three projects produce byte-for-byte identical diagnostics to `main`.
Author
Parents
Loading