mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-23 01:50:49 +08:00
## Summary We reduce `Expr` from 64 to 56 bytes on 64-bit targets. The largest variants determine the enum's size, so shrinking those variants saves eight bytes in every `Expr` value, including expressions in the parsed modules retained by ty. The changes are: - Store positional call arguments in `ThinVec`, reducing `Arguments` and `ExprCall` by eight bytes. - Store all comparison operands in one boxed slice. This removes the separate left-operand allocation and reduces `ExprCompare` by eight bytes while keeping operators in a boxed slice. - Store dictionary-comprehension generators in a boxed slice, reducing `ExprDictComp` by eight bytes. - Store f-string and t-string elements in boxed slices, and represent a single f-string directly as `FString`. This keeps single parts inline and reduces `ExprFString` and `ExprTString` by eight bytes. The parser, AST visitors, formatter, lint rules, and type inference use the updated layouts. Size assertions cover the 56-byte enum and its affected variants.
ruff_python_codegen
This crate is an internal component of Ruff. The Rust API exposed here is unstable and will have frequent breaking changes.
This version (0.0.13) is a component of Ruff 0.16.7. The source can be found here.
See Ruff's crate versioning policy for details on versioning.