Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Compact retained function type signatures#25669

Merged
charliermarsh merged 3 commits into
mainfrom
charlie/compact-function-type-payloads
Jun 5, 2026
Merged

[ty] Compact retained function type signatures#25669
charliermarsh merged 3 commits into
mainfrom
charlie/compact-function-type-payloads

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

FunctionType currently stores its optional updated callable signature and optional updated implementation signature inline. Ordinary function types have neither, but every interned value still reserves space for both.

This groups the uncommon updated signatures into one boxed payload. Ordinary function types retain only the function literal and an empty optional pointer; specialized function types pay at most one allocation and continue to expose the same signatures.

On a representative package, this reduced retained FunctionType memory by 56% and total retained memory by 1.05 MB (0.35%). A ten-run isolated comparison showed no runtime regression.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jun 5, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 92.16%. The percentage of expected errors that received a diagnostic held steady at 87.31%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 38.34MB 38.20MB -0.38% (149.46kB) ⬇️
trio 97.35MB 96.80MB -0.56% (562.87kB) ⬇️
sphinx 233.93MB 232.65MB -0.55% (1.28MB) ⬇️
prefect 639.94MB 635.45MB -0.70% (4.49MB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
FunctionType 430.38kB 280.91kB -34.73% (149.46kB) ⬇️

trio

Name Old New Diff Outcome
FunctionType 1.40MB 873.51kB -39.19% (562.87kB) ⬇️

sphinx

Name Old New Diff Outcome
FunctionType 3.18MB 1.91MB -40.10% (1.28MB) ⬇️

prefect

Name Old New Diff Outcome
FunctionType 9.30MB 4.81MB -48.26% (4.49MB) ⬇️

@astral-sh-bot

astral-sh-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review June 5, 2026 17:59
@charliermarsh charliermarsh marked this pull request as draft June 5, 2026 18:00
@charliermarsh charliermarsh marked this pull request as ready for review June 5, 2026 18:06
@charliermarsh charliermarsh marked this pull request as draft June 5, 2026 18:10
@charliermarsh charliermarsh marked this pull request as ready for review June 5, 2026 18:19
@charliermarsh charliermarsh merged commit a3ee768 into main Jun 5, 2026
59 checks passed
@charliermarsh charliermarsh deleted the charlie/compact-function-type-payloads branch June 5, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants