mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-21 19:04:33 +00:00
![]() 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. |
||
---|---|---|
.. | ||
src | ||
ast.toml | ||
Cargo.toml | ||
generate.py |