Hello, On Wed, 2 Dec 2020 02:39:38 +1100 Chris Angelico <ros...@gmail.com> wrote:
> On Wed, Dec 2, 2020 at 2:29 AM Paul Sokolovsky <pmis...@gmail.com> > wrote: > > def fun(): > > # Imports are not allowed at run-time > > import mod2 > > # But you can re-import module previously imported at > > import-time. import mod > > Wait, what? No. No no no. Please do not do ANYTHING like this. Having > suffered under JavaScript's highly restrictive import system (and > actually been glad for it, since the alternative is far worse), I do > not want ANY version of Python to give up the full power of its import Then it's luck that ALL versions and dialects of Python aren't under your control ;-). > system, including the ability for a module to be imported only when > it's actually needed. Imports inside functions allow a program to have > optional dependencies, or dependencies that might be slow to load (eg > numpy), and without that, even running your script with "--help" has > to process every single import in the entire file. But didn't you you already spotted a line which says that the strict mode also aspires to improve on the Python module practices? Under strict mode's firm but benevolent rule, there won't be slowly-loading modules any more. All imports will be fast. And modules which want to be slow will do that in their module.init() function. > > -1000. I also forgot to mention very important point in the intro: when you read this proposal, please don't think about "CPython". That for sure will send you the wrong vibes. Think about "Python". ;-) > > ChrisA -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/GKRUGXJVZYFBTHD27IPY5NXF6CNDDI3S/ Code of Conduct: http://python.org/psf/codeofconduct/