ruff/crates/red_knot_python_semantic/resources/mdtest/annotations
Carl Meyer a1f361949e
[red-knot] optimize building large unions of literals (#17403)
## Summary

Special-case literal types in `UnionBuilder` to speed up building large
unions of literals.

This optimization is extremely effective at speeding up building even a
very large union (it improves the large-unions benchmark by 41x!). The
problem we can run into is that it is easy to then run into another
operation on the very large union (for instance, narrowing may add it to
an intersection, which then distributes it over the intersection) which
is still slow.

I think it is possible to avoid this by extending this optimized
"grouped" representation throughout not just `UnionBuilder`, but all of
our union and intersection representations. I have some work in this
direction, but rather than spending more time on it right now, I'd
rather just land this much, along with a limit on the size of these
unions (to avoid building really big unions quickly and then hitting
issues where they are used.)

## Test Plan

Existing tests and benchmarks.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-04-16 13:55:37 +00:00
..
annotated.md Special-case value-expression inference of special form subscriptions (#16877) 2025-03-20 21:46:02 +00:00
any.md [red-knot] Understand Annotated (#14950) 2024-12-13 09:41:37 -08:00
callable.md [red-knot] improve function/bound method type display (#17294) 2025-04-14 15:56:18 -07:00
deferred.md [red-knot] fix eager nested scopes handling (#16916) 2025-03-28 11:11:56 -04:00
int_float_complex.md Use python.typing.org for typing documentation links (#17323) 2025-04-09 20:38:20 +02:00
invalid.md [red-knot] Ban most Type::Instance types in type expressions (#16872) 2025-03-20 15:19:56 -07:00
literal.md [red-knot] optimize building large unions of literals (#17403) 2025-04-16 13:55:37 +00:00
literal_string.md Use python.typing.org for typing documentation links (#17323) 2025-04-09 20:38:20 +02:00
never.md [red-knot] Statically known branches (#15019) 2024-12-21 11:33:10 +01:00
new_types.md red_knot_python_semantic: replace one use of "old" secondary diagnostic messages 2025-04-10 13:21:00 -04:00
optional.md [red-knot] Make' Type::in_type_expression()' exhaustive for Type::KnownInstance (#16836) 2025-03-19 07:36:28 -07:00
starred.md [red-knot] function parameter types (#14802) 2024-12-06 12:55:56 -08:00
stdlib_typing_aliases.md [red-knot] Add initial support for * imports (#16923) 2025-03-24 17:15:58 +00:00
string.md [red-knot] optimize building large unions of literals (#17403) 2025-04-16 13:55:37 +00:00
union.md [red-knot] Fix false positives on types.UnionType instances in type expressions (#17297) 2025-04-09 18:33:16 +01:00
unsupported_special_forms.md [red-knot] Add ParamSpecArgs and ParamSpecKwargs as KnownClass (#17086) 2025-03-31 10:52:23 +00:00
unsupported_type_qualifiers.md Show more precise messages in invalid type expressions (#16850) 2025-03-19 17:00:30 +00:00