3 ms·
I would gladly take a command line flag that I can pass to python that makes all module loading lazy. Unless you are writing scripts or very simple stuff runni
by veber-alex 1y ago
I would gladly take a command line flag that I can pass to python that makes all module loading lazy.
Unless you are writing scripts or very simple stuff running side effects when modules are loaded should be avoided at all cost anyway.
- xdfgh1112 1y agoThat's already part of the PIP. There is a flag to enable lazy imports for all possible imports.
- charliermarsh 1y agoThe PEP includes the ability to enable (or disable) lazy imports globally via a command-line flag or environment variable, in addition to the import syntax.
- _ZeD_ 1y ago> I would gladly take a command line flag that I can pass to python that makes all module loading lazy. oh, you want a "break my libraries" flag? :D seriously, in theory lazy imports may be "transparent" for common use cases, but I've saw too many modules rely on the side effects of the importing, that I understand why they needed to make this a "double opt in" feature
- zahlman 1y agoYou can do it today with a few lines of code, although the implementation I show is not particularly robust (since it works by metaprogramming the import system, of course other code could interfere): https://news.ycombinator.com/item?id=45467489 https://news.ycombinator.com/item?id=45467489