Skip to content

feat: lazy imports google auth#17679

Open
hebaalazzeh wants to merge 3 commits into
mainfrom
feature/lazy-imports-google-auth
Open

feat: lazy imports google auth#17679
hebaalazzeh wants to merge 3 commits into
mainfrom
feature/lazy-imports-google-auth

Conversation

@hebaalazzeh

Copy link
Copy Markdown
Contributor

Description

This PR initiates the rollout of our PEP 0810 lazy-loading architecture to google-auth, starting with the transport module.

By applying Python 3.15's native explicit lazy imports, we defer the eager parsing and compilation of heavy third-party networking wrappers (like requests, urllib3, and grpc). This acts as the first step in addressing the high initialization latency and peak memory footprints we're seeing on Serverless cold-starts.

Older Python runtimes (3.14 and below) safely ignore the __lazy_modules__ set and fall back to standard eager execution, meaning this introduces zero backwards compatibility risk.

(Note: We use fully-qualified, hardcoded module strings rather than dynamic __name__ injection to ensure static analysis tools and type checkers can safely infer the proxies).

Related Documents

Note: This PR was kept intentionally small for review speed. We will be executing an iterative rollout, extending this pattern to other heavy modules like oauth2 and compute_engine in fast follow-up PRs once this structural pattern is approved.

@hebaalazzeh hebaalazzeh marked this pull request as ready for review July 9, 2026 05:09
@hebaalazzeh hebaalazzeh requested review from a team as code owners July 9, 2026 05:09

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a __lazy_modules__ set in packages/google-auth/google/auth/transport/__init__.py to support lazy loading of transport modules. The review feedback correctly identifies an incorrect module name (_aiohttp_requests instead of aiohttp_requests) that would prevent lazy importing in Python 3.15+.

Comment thread packages/google-auth/google/auth/transport/__init__.py Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant