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

Skip to content

[ty] Avoid resolving overload sets for ordinary functions#25817

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/fast-path-non-overloaded-functions
Jun 10, 2026
Merged

[ty] Avoid resolving overload sets for ordinary functions#25817
charliermarsh merged 1 commit into
mainfrom
charlie/fast-path-non-overloaded-functions

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

FunctionLiteral currently resolves its overload chain through a tracked query whenever callers need its definitions or callable signature, even though most functions consist of one ordinary definition.

This records the common no-overload case when constructing the function literal and returns the empty overload set plus the last definition before entering the tracked collector. Definition iteration and signature construction reuse that shared result, while functions with overloads continue through the existing tracked implementation.

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

astral-sh-bot Bot commented Jun 10, 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.23%. The percentage of expected errors that received a diagnostic held steady at 87.42%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
flake8 35.36MB 35.26MB -0.29% (105.09kB) ⬇️
trio 87.65MB 87.17MB -0.55% (493.17kB) ⬇️
sphinx 207.19MB 206.00MB -0.57% (1.18MB) ⬇️
prefect 562.57MB 558.66MB -0.70% (3.91MB) ⬇️

Significant changes

Click to expand detailed breakdown

flake8

Name Old New Diff Outcome
overloads_and_implementation_inner 79.47kB 10.98kB -86.19% (68.49kB) ⬇️
FunctionType 212.94kB 225.05kB +5.69% (12.11kB) ⬇️
infer_scope_types_impl 788.72kB 780.71kB -1.01% (8.00kB) ⬇️
member_lookup_with_policy_inner 405.30kB 397.46kB -1.93% (7.84kB) ⬇️
infer_definition_types 1.53MB 1.53MB -0.40% (6.35kB) ⬇️
infer_expression_types_impl 974.41kB 969.27kB -0.53% (5.14kB) ⬇️
FunctionType<'db>::signature_ 278.88kB 274.10kB -1.71% (4.78kB) ⬇️
cached_protocol_interface 56.45kB 52.76kB -6.54% (3.69kB) ⬇️
function_known_decorators 146.02kB 143.05kB -2.03% (2.96kB) ⬇️
infer_deferred_types 442.94kB 440.35kB -0.58% (2.59kB) ⬇️
BoundMethodType<'db>::bound_signatures_ 32.66kB 30.33kB -7.14% (2.33kB) ⬇️
BoundMethodType<'db>::into_callable_type_ 16.90kB 14.64kB -13.38% (2.26kB) ⬇️
when_constraint_set_assignable_to_owned_impl 159.03kB 157.59kB -0.91% (1.44kB) ⬇️
ClassType<'db>::abstract_methods_ 2.39kB 2.14kB -10.29% (252.00B) ⬇️
try_call_dunder_get_inner 20.68kB 20.46kB -1.08% (228.00B) ⬇️
... 12 more

trio

Name Old New Diff Outcome
overloads_and_implementation_inner 327.22kB 30.90kB -90.56% (296.32kB) ⬇️
infer_expression_types_impl 6.57MB 6.50MB -1.09% (73.23kB) ⬇️
infer_scope_types_impl 3.78MB 3.73MB -1.10% (42.34kB) ⬇️
FunctionType 697.92kB 739.48kB +5.96% (41.56kB) ⬇️
member_lookup_with_policy_inner 1.42MB 1.39MB -1.96% (28.49kB) ⬇️
infer_definition_types 6.43MB 6.41MB -0.34% (22.62kB) ⬇️
FunctionType<'db>::signature_ 745.16kB 726.77kB -2.47% (18.39kB) ⬇️
cached_protocol_interface 141.06kB 132.01kB -6.41% (9.05kB) ⬇️
ClassType<'db>::abstract_methods_ 34.05kB 26.52kB -22.13% (7.54kB) ⬇️
BoundMethodType<'db>::bound_signatures_ 97.24kB 89.84kB -7.62% (7.41kB) ⬇️
BoundMethodType<'db>::into_callable_type_ 53.65kB 46.32kB -13.65% (7.32kB) ⬇️
function_known_decorators 291.49kB 285.42kB -2.08% (6.07kB) ⬇️
infer_deferred_types 1.78MB 1.77MB -0.33% (5.98kB) ⬇️
all_narrowing_constraints_for_expression 1012.84kB 1010.49kB -0.23% (2.34kB) ⬇️
when_constraint_set_assignable_to_owned_impl 401.74kB 399.62kB -0.53% (2.12kB) ⬇️
... 15 more

sphinx

Name Old New Diff Outcome
overloads_and_implementation_inner 770.04kB 72.15kB -90.63% (697.89kB) ⬇️
infer_expression_types_impl 20.49MB 20.34MB -0.72% (150.97kB) ⬇️
infer_scope_types_impl 12.54MB 12.44MB -0.86% (111.01kB) ⬇️
member_lookup_with_policy_inner 5.64MB 5.53MB -1.92% (110.79kB) ⬇️
FunctionType 1.58MB 1.68MB +5.91% (95.90kB) ⬇️
infer_definition_types 20.21MB 20.15MB -0.33% (67.62kB) ⬇️
FunctionType<'db>::signature_ 1.79MB 1.75MB -2.30% (42.13kB) ⬇️
BoundMethodType<'db>::bound_signatures_ 409.66kB 379.54kB -7.35% (30.12kB) ⬇️
BoundMethodType<'db>::into_callable_type_ 213.61kB 183.75kB -13.98% (29.86kB) ⬇️
cached_protocol_interface 266.40kB 248.95kB -6.55% (17.45kB) ⬇️
when_constraint_set_assignable_to_owned_impl 1.50MB 1.49MB -0.83% (12.70kB) ⬇️
function_known_decorators 973.06kB 963.80kB -0.95% (9.26kB) ⬇️
infer_deferred_types 4.01MB 4.00MB -0.21% (8.53kB) ⬇️
try_call_dunder_get_inner 335.28kB 329.98kB -1.58% (5.30kB) ⬇️
all_narrowing_constraints_for_expression 4.12MB 4.11MB -0.07% (3.13kB) ⬇️
... 17 more

prefect

Name Old New Diff Outcome
overloads_and_implementation_inner 2.63MB 68.88kB -97.44% (2.56MB) ⬇️
infer_scope_types_impl 47.64MB 47.21MB -0.90% (441.53kB) ⬇️
infer_expression_types_impl 55.21MB 54.84MB -0.67% (379.41kB) ⬇️
infer_definition_types 74.04MB 73.75MB -0.40% (306.79kB) ⬇️
FunctionType 4.15MB 4.44MB +6.99% (296.91kB) ⬇️
member_lookup_with_policy_inner 13.53MB 13.27MB -1.90% (263.55kB) ⬇️
FunctionType<'db>::signature_ 2.93MB 2.86MB -2.46% (73.88kB) ⬇️
cached_protocol_interface 538.55kB 502.95kB -6.61% (35.60kB) ⬇️
BoundMethodType<'db>::bound_signatures_ 467.33kB 434.80kB -6.96% (32.53kB) ⬇️
BoundMethodType<'db>::into_callable_type_ 234.45kB 202.25kB -13.73% (32.19kB) ⬇️
ClassType<'db>::abstract_methods_ 146.32kB 125.41kB -14.29% (20.91kB) ⬇️
function_known_decorators 3.92MB 3.90MB -0.50% (20.25kB) ⬇️
when_constraint_set_assignable_to_owned_impl 3.04MB 3.02MB -0.65% (20.18kB) ⬇️
infer_deferred_types 9.00MB 8.98MB -0.17% (15.46kB) ⬇️
all_narrowing_constraints_for_expression 13.21MB 13.20MB -0.09% (11.82kB) ⬇️
... 23 more

@astral-sh-bot

astral-sh-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@codspeed-hq

codspeed-hq Bot commented Jun 10, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 9.85%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 66 untouched benchmarks
⏩ 60 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ty_micro[typevar_mapping_small_accumulations] 216.3 ms 196.9 ms +9.85%

Tip

Curious why this is faster? Use the CodSpeed MCP and ask your agent.


Comparing charlie/fast-path-non-overloaded-functions (70ff9c0) with main (13e4a58)

Open in CodSpeed

Footnotes

  1. 60 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@charliermarsh charliermarsh force-pushed the charlie/fast-path-non-overloaded-functions branch from 69e7908 to 0cfb21c Compare June 10, 2026 13:08
@charliermarsh charliermarsh added the performance Potential performance improvement label Jun 10, 2026
@charliermarsh charliermarsh force-pushed the charlie/fast-path-non-overloaded-functions branch 2 times, most recently from 37ef30f to ca6f7e9 Compare June 10, 2026 13:33
@charliermarsh charliermarsh force-pushed the charlie/fast-path-non-overloaded-functions branch from ca6f7e9 to 70ff9c0 Compare June 10, 2026 13:55
@charliermarsh charliermarsh marked this pull request as ready for review June 10, 2026 13:56

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!!

@AlexWaygood AlexWaygood self-requested a review June 10, 2026 14:07
@charliermarsh charliermarsh merged commit 934cfa9 into main Jun 10, 2026
59 checks passed
@AlexWaygood AlexWaygood assigned AlexWaygood and unassigned sharkdp Jun 10, 2026
@charliermarsh charliermarsh deleted the charlie/fast-path-non-overloaded-functions branch June 10, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Potential performance improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants