Commit 63caee8
committed
feat: lazy imports gapic v1 (#17673)
## Description
This PR initiates the rollout of our PEP 0810 lazy-loading architecture
to google-api-core, starting with the `gapic_v1` module.
By applying Python 3.15's native explicit lazy imports, we defer the
eager execution of inner modules (like `method.py` and `config.py`)
which recursively pull in massive third-party C-extensions like
`grpcio`. 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, and provide explicit type annotations
(`Set[str]`), to ensure static analysis tools and type checkers can
safely infer the proxies without complaints).*
## Related Documents
* **Design Doc:** go/sdk:api-core-lazy-loading
* **Original GAPIC Generator Implementation PR:** #175911 parent 3f5ad03 commit 63caee8
1 file changed
Lines changed: 40 additions & 14 deletions
Lines changed: 40 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 15 | + | |
| 16 | + | |
21 | 17 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments