7 ms·
Personally, unless it has explicit "lazy" syntax I kind of hate the idea. One thing I always liked about python was how predictable and simple module imports ar
by overgard 4y ago
Personally, unless it has explicit "lazy" syntax I kind of hate the idea. One thing I always liked about python was how predictable and simple module imports are.
- slaymaker1907 4y agoI think such a mechanism already exists. You can just use the functional import syntax inside of a block. However, I think lazy imports could be ok so long as the language can show that a particular module is side effect free (i.e. no globals aside from something like constexpr).
- masklinn 4y ago> You can just use the functional import syntax inside of a block. You don't even need functional import syntax, but as TFA notes this comes at a cost as it has to invoke the entire import machinery, which it can only skip to an extent (once a module is loaded and cached) as import hooks can have odd behaviours.
- andreareina 4y agoI wouldn’t call different behaviour whether there’s __init__.py predictable nor simple. Also relative imports not working in an interactive session.