Open
Description
In #93, we add type_params: Vec
to ClassDef
and FunctionDef
which increases the size of a statement. We may want to optimize this field to reduce the size of the statement struct.
The main reason for the assertion is to be aware of how changing the AST changes its size. This is important because ruff and RustPython hold many instances of these types and increasing their size mean:
- Each element in a
Vec
now requires more storage -> Overall increased memory consumption- Reading or writing an element becomes slower because your computer must read or write more bytes. This is especially relevant for reading where the L1 cache short circuits reads by caching about 64 bytes of neighboring memory to avoid subsequent reads from (the very slow) memory.
There's not much we can do about this here. This could be a place where using
tinyvec
over a regularVec
would be beneficial, considering that the vec will be empty for almost all instances. But I think this is fine for now.
Originally posted by @MichaReiser in #93 (comment)
Metadata
Metadata
Assignees
Labels
No labels