Skip to content

[ty] Inline short AST string literals - #27601

Closed
charliermarsh wants to merge 1 commit into
mainfrom
charlie/compact-ast-string-literals
Closed

charliermarsh wants to merge 1 commit into
mainfrom
charlie/compact-ast-string-literals

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

Store regular string literals and interpolated-string literal segments in CompactString instead of Box<str>, avoiding separate heap allocations for short values.

Update parser construction, Ruff rule autofixes, formatter normalization, AST comparison, and ty IDE references to use the new representation. Formatter normalization can now append directly to an existing literal instead of converting through an intermediate String.

CompactString increases ExprFString from 56 to 64 bytes on 64-bit targets; the enclosing Expr remains 72 bytes on main. This isolates the allocation-versus-layout tradeoff from the separate expression-size reduction in #27591.

@astral-sh-bot

astral-sh-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 40.38MB 40.34MB -0.10% (42.77kB) ⬇️
trio 93.28MB 93.21MB -0.07% (69.59kB) ⬇️
sphinx 164.92MB 164.82MB -0.06% (108.88kB) ⬇️
prefect 453.68MB 453.43MB -0.05% (253.21kB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
parsed_module 15.50MB 15.46MB -0.27% (42.77kB) ⬇️

trio

Name Old New Diff Outcome
parsed_module 23.25MB 23.19MB -0.29% (69.59kB) ⬇️

sphinx

Name Old New Diff Outcome
parsed_module 34.30MB 34.20MB -0.31% (108.88kB) ⬇️

prefect

Name Old New Diff Outcome
parsed_module 89.10MB 88.85MB -0.28% (253.21kB) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant