Skip to content

Avoid allocating when parsing single string literals - #26200

Merged
MichaReiser merged 1 commit into
astral-sh:mainfrom
MichaReiser:micha/lazy-string-parser-allocation
Jun 22, 2026
Merged

MichaReiser merged 1 commit into
astral-sh:mainfrom
MichaReiser:micha/lazy-string-parser-allocation

Conversation

@MichaReiser

Copy link
Copy Markdown
Member

Summary

Parse a single string directly and allocate a collection only for implicit string concatenation.
Paired profiles save 1–2.4 MB on smaller projects, with estimated savings of 15–46 MB on Sphinx and Prefect and neutral timing.

Test Plan

Testing: Passed the parser test suite, workspace Clippy, hooks, and multi-project output and timing checks.

@MichaReiser MichaReiser added performance Potential performance improvement parser Related to the parser labels Jun 22, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
prefect 524.24MB 524.25MB +0.00% (9.76kB) ⏫
trio 78.60MB 78.59MB -0.01% (8.28kB) ⬇️
sphinx 195.80MB 195.80MB -0.00% (8.77kB) ⬇️
flake8 31.37MB 31.35MB -0.05% (15.76kB) ⬇️

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
parsed_module 19.35MB 19.36MB +0.05% (9.76kB) ⏫

trio

Name Old New Diff Outcome
parsed_module 15.05MB 15.04MB -0.05% (8.28kB) ⬇️

sphinx

Name Old New Diff Outcome
parsed_module 18.37MB 18.36MB -0.05% (8.77kB) ⬇️

flake8

Name Old New Diff Outcome
parsed_module 9.78MB 9.76MB -0.16% (15.76kB) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected βœ…

Full report with detailed diff (timing results)

@astral-sh-bot

astral-sh-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

βœ… ecosystem check detected no linter changes.

Linter (preview)

βœ… ecosystem check detected no linter changes.

Formatter (stable)

βœ… ecosystem check detected no format changes.

Formatter (preview)

βœ… ecosystem check detected no format changes.

@MichaReiser
MichaReiser marked this pull request as ready for review June 22, 2026 05:53
@MichaReiser
MichaReiser requested a review from dhruvmanila as a code owner June 22, 2026 05:53
@MichaReiser
MichaReiser merged commit ae306a0 into astral-sh:main Jun 22, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parser Related to the parser performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant