Skip to content

Comments

[ty] Decompose bool to Literal[True, False] in unions and intersections (v2)#15773

Closed
AlexWaygood wants to merge 3 commits intomainfrom
alex/truthy-unions-6
Closed

[ty] Decompose bool to Literal[True, False] in unions and intersections (v2)#15773
AlexWaygood wants to merge 3 commits intomainfrom
alex/truthy-unions-6

Conversation

@AlexWaygood
Copy link
Member

Summary

An alternative to #15738, which might be slightly more readable and easier to reason about. I'm also curious to see how this compares with the Codspeed benchmarks.

Test Plan

Same tests as #15738

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Jan 27, 2025
@AlexWaygood
Copy link
Member Author

@sharkdp -- curious if you find this more or less easy to understand than #15738? The final commit here is the only difference between the two. (I'll add a comment to the branch about boolean literals delegating to KnownClass::Int whichever of the two we decide we prefer for readability.)

Performance seems to be basically the same between the two. Maybe this one is a tiny bit slower? But it could just be noise.

@AlexWaygood AlexWaygood changed the title [red-knot] Decompose bool to Literal[True, False] in unions and intersections (v2) [ty] Decompose bool to Literal[True, False] in unions and intersections (v2) Jan 14, 2026
@AlexWaygood
Copy link
Member Author

AlexWaygood commented Feb 16, 2026

very merge-conflicted

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