Files
Charlie Marsh 08aac42edb Coalesce source slices when formatting attributes (#29841)
## Summary

Formatting and printing the top-level modules in CPython’s standard
library took 3.9% less time in a local benchmark (125.7 ms to 120.8 ms),
or 2.4% less with parsing included. CodSpeed reports a 5.1% efficiency
improvement on the [`large/dataset.py` formatter
benchmark](https://github.com/astral-sh/ruff/pull/29841#issuecomment-6515803489).

Today the formatter emits a source slice for `a`, a dot token, and a
source slice for `b` just to print `a.b`. We now emit the whole
expression as one slice when the dot touches both names, the first name
is unparenthesized, and there are no comments or call-chain breaks to
handle. Reading directly from the source also preserves Unicode
spellings like `𝓪.𝓫`.

For `factory().attr`, we still format the call and handle any line break
before the dot, but we can emit `.attr` as one slice. This follows the
approach in [Oxc #28462](https://github.com/oxc-project/oxc/pull/28462).
2026-10-30 21:16:18 +00:00
..