Skip to content

Commit b722f13

Browse files
authored
Merge pull request #34 from sacredvoid/perf/cache-lazy-imports
perf: cache lazy imports in module globals after first resolution
2 parents c97497d + af6ddab commit b722f13

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/alignrl/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
def __getattr__(name: str):
3232
if name in _LAZY_IMPORTS:
3333
module = importlib.import_module(_LAZY_IMPORTS[name])
34-
return getattr(module, name)
34+
attr = getattr(module, name)
35+
globals()[name] = attr
36+
return attr
3537
raise AttributeError(f"module 'alignrl' has no attribute {name!r}")
3638

3739

0 commit comments

Comments
 (0)