Use lazy module imports now - Graham Dumpleton
Briefly

Use lazy module imports now - Graham Dumpleton
"Before I explain how to use this new feature of wrapt, I do acknowledge that implementations for lazy module imports have existed for many years. That said, where they exist as separate Python libraries the few I found hadn't seem to have been touched in quite a while. Sure the concept probably works as it was implemented, but it can be disconcerting to see no updates and one could conclude the package has been abandoned."
"The proposed implementation outlined in the PEP would also eliminate one of the criticisms of lazy module importers that already existed. This was that it was necessary to patch sys.modules to add in a standin for a module before it was first imported. This was needed to be done explicitly, or it was necessary to add a special import loader to the Python runtime configuration. Either way, it was necessary to modify startup code for an application to install the patch or loader."
wrapt 2.0.0 adds a lazy object proxy and an extra top-level function in the public API to simplify lazy module imports. Several separate lazy import libraries exist but many show little recent maintenance, which can discourage adoption. wrapt offers a supported option for opting into lazy imports. PEP 810 proposes explicit lazy import syntax to make lazy imports a first-class Python feature. The PEP approach would remove the need to patch sys.modules or install special import loaders at startup and would avoid forcing lazy behavior on all importers of a module, preventing unintended side effects.
Read at Grahamdumpleton
Unable to calculate read time
[
|
]