ruff
a1f36194 - [red-knot] optimize building large unions of literals (#17403)

Commit
156 days ago
[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>
Author
Parents
Loading