Ruff Switches Ruff_python_ast::Name To 16-Byte CharStr For Memory Savings
Source Posts on X
I ended up forking https://github.com/ryota2357/lean_string (which looks like a very nice crate) to add support for an immutable variant and some other API niceties for our use-cases, but was also able to upstream some UB fixes and performance improvements.
- Reduced our small string size from from 24-bytes inline to 16-bytes inline. Much better tradeoff after analyzing a bunch of Python code (and in turn reduced the size of various AST nodes).
- Use reference-counting for heap-allocated strings so that we can cheaply clone / share for longer names that are reused across a given file.