ruff/crates/ruff_python_ast
Douglas Creager 444b055cec
[red-knot] Use ternary decision diagrams (TDDs) for visibility constraints (#15861)
We now use ternary decision diagrams (TDDs) to represent visibility
constraints. A TDD is just like a BDD ([_binary_ decision
diagram](https://en.wikipedia.org/wiki/Binary_decision_diagram)), but
with "ambiguous" as an additional allowed value. Unlike the previous
representation, TDDs are strongly normalizing, so equivalent ternary
formulas are represented by exactly the same graph node, and can be
compared for equality in constant time.

We currently have a slight 1-3% performance regression with this in
place, according to local testing. However, we also have a _5× increase_
in performance for pathological cases, since we can now remove the
recursion limit when we evaluate visibility constraints.

As follow-on work, we are now closer to being able to remove the
`simplify_visibility_constraint` calls in the semantic index builder. In
the vast majority of cases, we now see (for instance) that the
visibility constraint after an `if` statement, for bindings of symbols
that weren't rebound in any branch, simplifies back to `true`. But there
are still some cases we generate constraints that are cyclic. With
fixed-point cycle support in salsa, or with some careful analysis of the
still-failing cases, we might be able to remove those.
2025-02-04 14:32:11 -05:00
..
src [red-knot] Use ternary decision diagrams (TDDs) for visibility constraints (#15861) 2025-02-04 14:32:11 -05:00
ast.toml Remove customizable reference enum names (#15647) 2025-01-21 13:46:31 -05:00
Cargo.toml Remove the optional salsa dependency from the AST crate (#14363) 2024-11-15 16:46:04 +00:00
generate.py Remove customizable reference enum names (#15647) 2025-01-21 13:46:31 -05:00