An interesting point in the lazy imports design space that I hadn't
previously considered could be:

- lazy imports are explicitly marked and usage of the imported name
within the module is transparent, but
- lazily imported names are _not_ visible in the module namespace;
they can't be accessed by other modules or re-exported; they are
internal-use-only within the module

This compromise would, I think, make it possible to implement lazy
imports entirely in the compiler (effectively as syntax sugar for an
inline import at every usage site), which is definitely an
implementation improvement.

I think in practice explicitly marking lazy imports would make it
somewhat harder to gain the benefits of lazy imports for e.g. speeding
up startup time in a large CLI, compared to an implicit/automatic
approach. But still could be usable to get significant benefits.

Carl
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ZT6CXQPFCWZD2M65YXCSAPPGNDGA6WNE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to