3 ms·
It'd be pretty easy to do the experiment, since you can override the import logic and do lazy imports, eg. class LazyModule: def __init__(self, nam
by marmaduke 9y ago
It'd be pretty easy to do the experiment, since you can override the import logic and do lazy imports, eg.
class LazyModule:
def __init__(self, name):
self.name = name
def __getattr__(self, key):
mod = {}
exec('import %s as mod', mod)
self.mod = mod['mod']
return getattr(self.mod, key)
class LazyImporter:
def get_module(self, name):
return LazyModule(name)