On Sun, 10 Apr 2022, 15:53 Guido van Rossum, <[email protected]> wrote:
> On Sun, Apr 10, 2022 at 2:31 AM Daniel Pope <[email protected]> wrote: > >> On Fri, 8 Apr 2022, 17:44 Guido van Rossum, <[email protected]> wrote: >> >>> The interesting idea here seems to make "lazy imports" easier to >>> implement by making them explicit in the code. So far, most lazy import >>> frameworks for Python have done hacks with `__getattribute__` overrides. >>> >> >> The value is more than ease of implementation. Having syntax for import >> expressions makes them statically analysable, which is needed for type >> checkers and IDE autocompletion. >> > > This has been brought up a few times and I don't get it. Currently a use > of an imported module is perfectly analyzable by all the static type > checkers I know of (e.g. mypy, Pyre, pyright). > I was comparing a hypothetical import expression syntax with alternatives like __getattribute__ hacks, which I take to mean somemagicobject.package.module.attribute, or as other have suggested, importlib.import_module(). I believe those are not statically analysable at least without special casing them in the type checker. An import expression would be just as statically analysable as a statement, while being more ergonomic in certain situations. >
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/2UXMBKQJHN5AM3FKDUZ4DEF7TPD4HGYP/ Code of Conduct: http://python.org/psf/codeofconduct/
