Uh oh!
There was an error while loading. Please reload this page.
feat(core): implement PEP 0810 explicit lazy imports in google-cloud-core - #18052
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements PEP 0810 explicit lazy imports (lazy_modules) across several modules in google-cloud-core to optimize cold starts and memory footprints in Python 3.15+. The review feedback correctly identifies that using importlib.util.find_spec on submodules (such as google.auth.api_key) eagerly imports their parent packages, which defeats the purpose of lazy loading. The reviewer suggests using module-level getattr to defer the resolution of HAS_GOOGLE_AUTH_API_KEY until it is actually accessed.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
88be17b to
8f73f3bCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…core This PR implements PEP 0810 explicit lazy imports in google-cloud-core. On Python 3.15+, this defers loading of heavy inner modules and third-party dependencies (grpcio, cryptography, requests, and protobuf descriptor pools) to reduce serverless cold starts and memory footprints. On Python 3.14 and below, this falls back safely to eager execution with zero backwards-compatibility risk. ### Related Links - GAPIC Implementation PR: #17591 - google-api-core gapic_v1 PR: #17673 - google-api-core operations_v1 PR: #17724 - google-auth transport PR: #17679
8f73f3b to
b7f4f01Compare
This PR implements PEP 0810 explicit lazy imports in google-cloud-core.
On Python 3.15+, this defers loading of heavy inner modules and third-party dependencies (grpcio, cryptography, requests, and protobuf descriptor pools) to reduce serverless cold starts and memory footprints.
On Python 3.14 and below, this falls back safely to eager execution with zero backwards-compatibility risk.
Related Links
Design doc: go/sdk:python-lazy-loading