(self, module)
Make the module load lazily.
Make the module load lazily.
Make the module load lazily .
def exec_module(self, module):
        """Make the module load lazily."""
        module.__spec__.loader = self.loader
        module.__loader__ = self.loader
        # Don't need to worry about deep-copying as trying to set an attribute
        # on an object would have triggered the load,
        # e.g. ``module.__spec__.loader = None`` would trigger a load from
        # trying to access module.__spec__.
        loader_state = {}
        loader_state['__dict__'] = module.__dict__.copy()
        loader_state['__class__'] = module.__class__
        module.__spec__.loader_state = loader_state
        module.__class__ = _LazyModule
def exec_module ( self , module ) : module . __spec__ . loader = self . loader module . __loader__ = self . loader # Don't need to worry about deep-copying as trying to set an attribute # on an object would have triggered the load, # e.g. ``module.__spec__.loader = None`` would trigger a load from # trying to access module.__spec__. loader_state = { } loader_state [ '__dict__' ] = module . __dict__ . copy ( ) loader_state [ '__class__' ] = module . __class__ module . __spec__ . loader_state = loader_state module . __class__ = _LazyModule