[ty] Compact retained use-def bindings by charliermarsh · Pull Request #25682 · astral-sh/ruff (original) (raw)
Summary
UseDefMap currently retains every interned binding state as a SmallVec, including builder-only capacity and an optional unbound constraint that are no longer needed after semantic indexing finishes.
This change packs the shadowing policy into the scope-local definition ID and stores retained binding states as ranges into one contiguous LiveBinding array. Binding construction and interning behavior remain unchanged, while each LiveBinding shrinks from 16 to 12 bytes and retained states no longer carry per-vector allocation metadata.
On a large codebase, this reduced retained memory by 2.96% without a wall-time regression.