[ty] Use same-file expression inference in reachability by charliermarsh · Pull Request #25694 · astral-sh/ruff (original) (raw)
Summary
Reachability currently calls infer_expression_type for each expression that it evaluates. This creates and retains a separate Salsa query for every expression, even though reachability only evaluates predicates from the same file as the enclosing query.
This uses infer_same_file_expression_type instead. The underlying infer_expression_types query continues to provide caching and cycle recovery, while cross-file callers continue through infer_expression_type; reachability avoids retaining the redundant single-expression query layer.
Across the memory-report projects, retained infer_expression_type_impl memory fell by 88% to 95%, reducing total retained memory by 0.15% to 0.68% without diagnostic changes.