For the PEP, I was just interested in if we could move the import of importlib in the example code. The example code for lazy submodule imports is
# lib/__init__.py
import importlib
__all__ = ['submod', ...]
def __getattr__(name):
if name in __all__:
return importlib.import_module("." + name, __name__)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
I was just wondering if we could move the import of importlib into __getattr__
as that fixes the Jep issue with sub-interpreters and organizations like scipy are following that code almost exactly. But it sounds like the PEP can’t be changed.
So then I don’t have any other changes to suggest, I was just hoping someone here might have the expertise to know how importlib could be improved or Jep could do things differently.