<div dir="ltr">It looks simple and easy to understand.<div><br></div><div>To achieve lazy import without breaking backward compatibility,</div><div>I want to add one more rule:  When package defines both of __getattr__ and __all__, automatic import of submodules are disabled (sorry, I don't have pointer to specification about this behavior).</div><div><br></div><div>For example, some modules depends on email.parser or email.feedparser.</div><div>But since email/__init__.py uses __all__, all submodules</div><div>are imported eagerly.</div><div><br></div><div>See <a href="https://github.com/python/cpython/blob/master/Lib/email/__init__.py#L7-L25">https://github.com/python/cpython/blob/master/Lib/email/__init__.py#L7-L25</a><br></div><div><br></div><div>Changing __all__ will break backward compatibility.</div><div>With __getattr__, this can be lazy import:</div><div><br></div><div>import importlib</div><div><br></div><div>def __getattr__(name):</div><div>    if name in __all__:</div><div>        return importlib.import_module("." + name, __name__)</div><div>    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")</div><div><br></div><div><br></div><div>Regards,</div></div>