Skip to content

Commit 2e9fe1b

Browse files
committed
fixup! feat(core.utils): derive __all__ from _LAZY_CACHE_ATTRS; document star-import caveat
Defines the ordered lazy-export tuple once and splices it into __all__ so the two lists cannot drift. Notes that star-import still eagerly resolves every lazy attribute (walking __all__ pulls _program_cache in), which is expected given star-imports are already discouraged.
1 parent e98f580 commit 2e9fe1b

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

cuda_core/cuda/core/utils/__init__.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,26 @@
77
args_viewable_as_strided_memory,
88
)
99

10-
__all__ = [
10+
# Lazily expose the program-cache APIs so ``from cuda.core.utils import
11+
# StridedMemoryView`` stays lightweight -- the cache backends pull in driver,
12+
# NVRTC, and module-load machinery that memoryview-only consumers do not need.
13+
# The laziness guarantee is for explicit imports only: ``from cuda.core.utils
14+
# import *`` walks ``__all__`` and therefore resolves every lazy attribute,
15+
# which eagerly pulls ``_program_cache`` in. Star-imports are discouraged
16+
# anyway, so treat that as expected.
17+
_LAZY_CACHE_ATTRS = (
1118
"FileStreamProgramCache",
1219
"ProgramCacheResource",
1320
"SQLiteProgramCache",
21+
"make_program_cache_key",
22+
)
23+
24+
__all__ = [
1425
"StridedMemoryView",
1526
"args_viewable_as_strided_memory",
16-
"make_program_cache_key",
27+
*_LAZY_CACHE_ATTRS,
1728
]
1829

19-
# Lazily expose the program-cache APIs so ``from cuda.core.utils import
20-
# StridedMemoryView`` stays lightweight -- the cache backends pull in driver,
21-
# NVRTC, and module-load machinery that memoryview-only consumers do not need.
22-
_LAZY_CACHE_ATTRS = frozenset(
23-
{
24-
"FileStreamProgramCache",
25-
"ProgramCacheResource",
26-
"SQLiteProgramCache",
27-
"make_program_cache_key",
28-
}
29-
)
30-
3130

3231
def __getattr__(name):
3332
if name in _LAZY_CACHE_ATTRS:

0 commit comments

Comments
 (0)