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

Skip to content

[ty] Bypass member lookup for module imports#25723

Merged
charliermarsh merged 1 commit into
mainfrom
codex/module-literal-member-lookup
Jun 7, 2026
Merged

[ty] Bypass member lookup for module imports#25723
charliermarsh merged 1 commit into
mainfrom
codex/module-literal-member-lookup

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

from module import name import inference already knows that the left-hand side resolved to a module literal, but it still routed the final attribute lookup through the generic Type::member path. That path handles arbitrary receiver types and descriptor behavior before eventually reaching module lookup.

This constructs the ModuleLiteralType directly, reuses it for the existing self-referential global-import guard, and calls ModuleLiteralType::static_member when checking whether the imported module exports the requested name. Import semantics stay the same, while module import lookup avoids the generic member-lookup machinery.

The now-unused Type::as_module_literal helper is removed.

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

astral-sh-bot Bot commented Jun 7, 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 7, 2026

Copy link
Copy Markdown

Memory usage report

Summary

Project Old New Diff Outcome
prefect 566.73MB 566.75MB +0.00% (14.13kB)
flake8 35.59MB 35.56MB -0.09% (33.32kB) ⬇️
trio 88.62MB 88.44MB -0.21% (191.52kB) ⬇️
sphinx 209.16MB 208.78MB -0.18% (392.29kB) ⬇️

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
infer_definition_types 75.67MB 75.91MB +0.31% (241.64kB)
member_lookup_with_policy_inner 13.65MB 13.54MB -0.86% (120.82kB)
member_lookup_with_policy_inner::interned_arguments 6.79MB 6.68MB -1.55% (107.81kB)
UnionType<'db>::from_two_elements_ 742.79kB 743.19kB +0.05% (412.00B)
UnionType 1.37MB 1.37MB +0.02% (240.00B)
UnionType<'db>::from_two_elements_::interned_arguments 613.94kB 614.11kB +0.03% (176.00B)
infer_scope_types_impl 47.63MB 47.63MB +0.00% (144.00B)
known_class_to_class_literal 7.66kB 7.70kB +0.46% (36.00B)
module_type_symbols 928.00B 964.00B +3.88% (36.00B)
place_by_id 5.04MB 5.04MB +0.00% (36.00B)
StaticClassLiteral<'db>::implicit_attribute_inner_ 1.00MB 1.00MB +0.00% (32.00B)
infer_expression_types_impl 55.18MB 55.18MB +0.00% (24.00B)
infer_expression_type_impl 390.12kB 390.14kB +0.00% (16.00B)

flake8

Name Old New Diff Outcome
member_lookup_with_policy_inner 431.61kB 404.52kB -6.28% (27.09kB) ⬇️
member_lookup_with_policy_inner::interned_arguments 226.76kB 201.80kB -11.01% (24.96kB) ⬇️
infer_definition_types 1.56MB 1.58MB +1.17% (18.63kB) ⬇️
known_class_to_class_literal 4.88kB 4.92kB +0.72% (36.00B) ⬇️
module_type_symbols 928.00B 964.00B +3.88% (36.00B) ⬇️
place_by_id 141.64kB 141.67kB +0.02% (36.00B) ⬇️

trio

Name Old New Diff Outcome
member_lookup_with_policy_inner 1.56MB 1.42MB -8.95% (142.52kB) ⬇️
member_lookup_with_policy_inner::interned_arguments 899.30kB 768.63kB -14.53% (130.66kB) ⬇️
infer_definition_types 6.53MB 6.61MB +1.22% (81.56kB) ⬇️
known_class_to_class_literal 6.39kB 6.42kB +0.55% (36.00B) ⬇️
module_type_symbols 928.00B 964.00B +3.88% (36.00B) ⬇️
place_by_id 568.27kB 568.30kB +0.01% (36.00B) ⬇️

sphinx

Name Old New Diff Outcome
member_lookup_with_policy_inner 5.94MB 5.64MB -5.13% (311.95kB) ⬇️
member_lookup_with_policy_inner::interned_arguments 2.91MB 2.66MB -8.67% (258.52kB) ⬇️
infer_definition_types 20.55MB 20.72MB +0.84% (177.56kB) ⬇️
IntersectionType 561.59kB 561.20kB -0.07% (400.00B) ⬇️
CallableType 1.37MB 1.37MB +0.02% (304.00B) ⬇️
UnionType<'db>::from_two_elements_ 292.44kB 292.57kB +0.04% (128.00B) ⬇️
UnionType 653.27kB 653.38kB +0.02% (112.00B) ⬇️
infer_expression_types_impl 20.48MB 20.48MB +0.00% (108.00B) ⬇️
is_redundant_with_impl::interned_arguments 1.14MB 1.14MB +0.01% (88.00B) ⬇️
UnionType<'db>::from_two_elements_::interned_arguments 265.80kB 265.89kB +0.03% (88.00B) ⬇️
is_redundant_with_impl 914.16kB 914.20kB +0.01% (48.00B) ⬇️
StaticClassLiteral<'db>::implicit_attribute_inner_ 699.10kB 699.14kB +0.01% (44.00B) ⬇️
known_class_to_class_literal 6.57kB 6.61kB +0.54% (36.00B) ⬇️
module_type_symbols 928.00B 964.00B +3.88% (36.00B) ⬇️
place_by_id 1.38MB 1.38MB +0.00% (36.00B) ⬇️
... 2 more

@astral-sh-bot

astral-sh-bot Bot commented Jun 7, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Full report with detailed diff (timing results)

@charliermarsh charliermarsh added the performance Potential performance improvement label Jun 7, 2026
@charliermarsh charliermarsh marked this pull request as ready for review June 7, 2026 12:24
@astral-sh-bot astral-sh-bot Bot requested a review from dhruvmanila June 7, 2026 12:24
@charliermarsh charliermarsh merged commit b16565e into main Jun 7, 2026
92 of 94 checks passed
@charliermarsh charliermarsh deleted the codex/module-literal-member-lookup branch June 7, 2026 12:24
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.

2 participants