Skip to content

[red-knot] micro-optimise ClassLiteral::is_protocol #17703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025

Conversation

AlexWaygood
Copy link
Member

Summary

I doubt it makes any significant difference to performance, but if Protocol is present in the bases list of a valid protocol class, it must either:

  1. be the last base
  2. or be the last-but-one base (with the final base being Generic[] or object)
  3. or be the last-but-two base (with the penultimate base being Generic[] and the final base being object)

Test Plan

Existing tests pass

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Apr 29, 2025
@AlexWaygood AlexWaygood enabled auto-merge (squash) April 29, 2025 12:34
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅

@AlexWaygood AlexWaygood merged commit 31e6576 into main Apr 29, 2025
32 checks passed
@AlexWaygood AlexWaygood deleted the alex/micro-optimise-is-protocol branch April 29, 2025 12:35
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