News for hackers. Stuff that matters.
Re:Optimizations which made Python 3.6 faster than Python 3.... by marmaduke on Friday June 09, 2017 @02:55PM (#14523540)
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)

There are no comments on this comment yet.