mirror of
https://github.com/astral-sh/ruff
synced 2026-01-07 14:44:17 -05:00
Box type params and arguments fields on the class definition node (#6275)
## Summary This PR boxes the `TypeParams` and `Arguments` fields on the class definition node. These fields are optional and often emitted, and given that class definition is our largest enum variant, we pay the cost of including them for every statement in the AST. Boxing these types reduces the statement size by 40 bytes, which seems like a good tradeoff given how infrequently these are accessed. ## Test Plan Need to benchmark, but no behavior changes.
This commit is contained in:
@@ -1199,10 +1199,10 @@ ClassDef: ast::Stmt = {
|
||||
ast::Stmt::ClassDef(
|
||||
ast::StmtClassDef {
|
||||
name,
|
||||
arguments,
|
||||
arguments: arguments.map(Box::new),
|
||||
body,
|
||||
decorator_list,
|
||||
type_params,
|
||||
type_params: type_params.map(Box::new),
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// auto-generated: "lalrpop 0.20.0"
|
||||
// sha3: aadf067e37a9f39d450f1403b759a9659c60e697758ddd2b8c2b5fa2d0d73672
|
||||
// sha3: f99d8cb29227bfbe1fa07719f655304a9a93fd4715726687ef40c091adbdbad5
|
||||
use num_bigint::BigInt;
|
||||
use ruff_text_size::TextSize;
|
||||
use ruff_python_ast::{self as ast, Ranged, MagicKind};
|
||||
@@ -33583,10 +33583,10 @@ fn __action170<
|
||||
ast::Stmt::ClassDef(
|
||||
ast::StmtClassDef {
|
||||
name,
|
||||
arguments,
|
||||
arguments: arguments.map(Box::new),
|
||||
body,
|
||||
decorator_list,
|
||||
type_params,
|
||||
type_params: type_params.map(Box::new),
|
||||
range: (location..end_location).into()
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user