Skip to content

[ty] Avoid bookkeeping for unannotated functions#24842

Merged
charliermarsh merged 1 commit intomainfrom
charlie/avoid-per
Apr 26, 2026
Merged

[ty] Avoid bookkeeping for unannotated functions#24842
charliermarsh merged 1 commit intomainfrom
charlie/avoid-per

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh commented Apr 26, 2026

Summary

If a function doesn't contain any annotations or default arguments, we don't need to do deferred inference for the signature; and if the function isn't decorated, we don't need to store a separate undecorated_type. This avoids a deferred-definition entry, an empty deferred inference query, and (oftena) an DefinitionInferenceExtra allocation.

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Apr 26, 2026
@charliermarsh charliermarsh added the internal An internal refactor or improvement label Apr 26, 2026
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 26, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 26, 2026

Memory usage report

Summary

Project Old New Diff Outcome
trio 116.38MB 116.36MB -0.02% (21.92kB) ⬇️
flake8 47.77MB 47.59MB -0.36% (177.41kB) ⬇️
sphinx 258.64MB 258.30MB -0.13% (350.28kB) ⬇️
prefect 706.22MB 700.60MB -0.80% (5.62MB) ⬇️

Significant changes

Click to expand detailed breakdown

trio

Name Old New Diff Outcome
infer_definition_types 7.54MB 7.53MB -0.13% (10.32kB) ⬇️
infer_deferred_types 2.34MB 2.33MB -0.30% (7.25kB) ⬇️
infer_scope_types_impl 4.71MB 4.71MB -0.04% (1.99kB) ⬇️
infer_expression_types_impl 7.00MB 7.00MB -0.03% (1.96kB) ⬇️
infer_expression_type_impl 1.31MB 1.31MB -0.01% (120.00B) ⬇️
all_narrowing_constraints_for_expression 596.51kB 596.43kB -0.01% (84.00B) ⬇️
loop_header_reachability 130.65kB 130.59kB -0.04% (60.00B) ⬇️
infer_statement_types_impl 23.87kB 23.82kB -0.20% (48.00B) ⬇️
all_negative_narrowing_constraints_for_expression 185.45kB 185.40kB -0.03% (48.00B) ⬇️
function_known_decorators 351.68kB 351.64kB -0.01% (48.00B) ⬇️

flake8

Name Old New Diff Outcome
infer_deferred_types 691.35kB 563.80kB -18.45% (127.55kB) ⬇️
infer_definition_types 1.85MB 1.81MB -2.43% (46.16kB) ⬇️
infer_scope_types_impl 986.41kB 982.71kB -0.37% (3.69kB) ⬇️

sphinx

Name Old New Diff Outcome
infer_deferred_types 5.52MB 5.27MB -4.44% (250.96kB) ⬇️
infer_definition_types 23.57MB 23.49MB -0.35% (85.42kB) ⬇️
infer_scope_types_impl 15.47MB 15.45MB -0.07% (10.93kB) ⬇️
infer_expression_types_impl 20.82MB 20.81MB -0.01% (1.85kB) ⬇️
infer_expression_type_impl 2.90MB 2.90MB -0.02% (492.00B) ⬇️
infer_unpack_types 437.20kB 436.96kB -0.05% (240.00B) ⬇️
all_narrowing_constraints_for_expression 2.39MB 2.39MB -0.01% (192.00B) ⬇️
loop_header_reachability 364.36kB 364.23kB -0.04% (132.00B) ⬇️
all_negative_narrowing_constraints_for_expression 1.05MB 1.05MB -0.01% (84.00B) ⬇️

prefect

Name Old New Diff Outcome
infer_deferred_types 14.62MB 11.09MB -24.13% (3.53MB) ⬇️
infer_definition_types 91.01MB 89.13MB -2.07% (1.88MB) ⬇️
infer_scope_types_impl 55.59MB 55.41MB -0.33% (189.97kB) ⬇️
infer_expression_types_impl 63.65MB 63.64MB -0.02% (11.02kB) ⬇️
infer_expression_type_impl 13.59MB 13.58MB -0.06% (7.96kB) ⬇️
StaticClassLiteral<'db>::implicit_attribute_inner_ 10.09MB 10.09MB -0.04% (4.17kB) ⬇️
Type<'db>::member_lookup_with_policy_ 17.30MB 17.29MB -0.01% (2.65kB) ⬇️
Type<'db>::class_member_with_policy_ 17.70MB 17.70MB -0.01% (1.52kB) ⬇️
all_narrowing_constraints_for_expression 7.38MB 7.38MB -0.02% (1.22kB) ⬇️
all_negative_narrowing_constraints_for_expression 2.69MB 2.69MB -0.01% (360.00B) ⬇️
StaticClassLiteral<'db>::variance_of_ 205.91kB 205.77kB -0.07% (144.00B) ⬇️
loop_header_reachability 430.38kB 430.32kB -0.01% (60.00B) ⬇️
infer_unpack_types 969.28kB 969.25kB -0.00% (24.00B) ⬇️
infer_statement_types_impl 222.38kB 222.37kB -0.01% (12.00B) ⬇️

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 26, 2026

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 26, 2026

Merging this PR will improve performance by 5.04%

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

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime pandas 70.1 s 66.8 s +5.04%

Comparing charlie/avoid-per (c6e0a03) with main (a241b1f)

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 marked this pull request as ready for review April 26, 2026 01:46
@astral-sh-bot astral-sh-bot Bot requested a review from oconnor663 April 26, 2026 01:47
@charliermarsh charliermarsh merged commit 1d287fa into main Apr 26, 2026
56 checks passed
@charliermarsh charliermarsh deleted the charlie/avoid-per branch April 26, 2026 01:47
@charliermarsh charliermarsh added the performance Potential performance improvement label Apr 26, 2026
carljm added a commit to tamird/ruff that referenced this pull request Apr 27, 2026
* main: (248 commits)
  [ty] bump conformance suite commit (astral-sh#24848)
  [ty] Pass unmapped type variables to `SpecializationBuilder::build_with` (astral-sh#24809)
  [ty] Avoid bookkeeping for unannotated functions (astral-sh#24842)
  [ty] Optimize signature checking based on number of arguments (astral-sh#24674)
  [ty] Avoid eagerly inferring legacy generic context (astral-sh#24841)
  [ty] Skip decorator inference for undecorated functions (astral-sh#24839)
  [ty] solve unions against generic protocols (astral-sh#24837)
  [ty] Lazily allocate parameter type builders (astral-sh#24838)
  [ty] Lazily compute call argument fallbacks (astral-sh#24836)
  [ty] Avoid collecting type context callables (astral-sh#24835)
  Bump ecosystem-analyzer to e7576e6 (astral-sh#24834)
  [ty] Support basic narrowing with aliased conditional expressions (astral-sh#24302)
  [ty] Fix project and workspace selection (astral-sh#24824)
  [ty] Fix missing memory usage attributes (astral-sh#24823)
  Fix setting selection for multi folder workspace (astral-sh#24819)
  Improve diagnostics for implicit calls to a possibly unbound unary operator. (astral-sh#24816)
  [ty] Update review pool (astral-sh#24818)
  Bump 0.15.12 (astral-sh#24815)
  [ty] Complete support for more detailed diagnostics on possibly unbound errors from implicit dunder calls against unions. (astral-sh#24676)
  Implement `#ruff:file-ignore` file-level suppressions (astral-sh#23599)
  ...
carljm added a commit that referenced this pull request Apr 27, 2026
* main: (44 commits)
  Update cargo-bins/cargo-binstall action to v1.18.1 (#24855)
  Update dependency ruff to v0.15.12 (#24857)
  Update taiki-e/install-action action to v2.75.18 (#24864)
  [ty] Model bool-op branch snapshots (#24458)
  [ty] Support `Unpack[TypedDict]` in `**kwargs` signatures (#24653)
  Update prek dependencies (#24858)
  Update Rust crate bitflags to v2.11.1 (#24859)
  Update Rust crate clap to v4.6.1 (#24860)
  Update Rust crate mimalloc to v0.1.49 (#24862)
  Update Rust crate uuid to v1.23.1 (#24863)
  Update Rust crate rayon to v1.12.0 (#24866)
  Update Rust crate libc to v0.2.185 (#24861)
  [ty] Reserve union element storage (#24849)
  [ty] bump conformance suite commit (#24848)
  [ty] Pass unmapped type variables to `SpecializationBuilder::build_with` (#24809)
  [ty] Avoid bookkeeping for unannotated functions (#24842)
  [ty] Optimize signature checking based on number of arguments (#24674)
  [ty] Avoid eagerly inferring legacy generic context (#24841)
  [ty] Skip decorator inference for undecorated functions (#24839)
  [ty] solve unions against generic protocols (#24837)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement performance Potential performance improvement ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants