On Tue, Dec 30, 2014 at 3:58 PM, Steven D'Aprano
For decimal, that's not much of an advantage, but some modules are quite expensive to import the first time, and you might not want to pay that cost at application start-up.
Even more so if this is done for _every module in the system_. I'm thinking of testing this out; creating a lazy import object for every single findable module, although before I start that, I'll see if I can hunt down a tab-completion routine rather than manually searching sys.path. In theory, enumerating modules shouldn't take too long (it's not like I have network mounts in PYTHONPATH), so if that's sufficiently fast, I might toss that into a permanent startup script, rather than having my current "import on NameError" trap. Small downside: This *does* require that the modules all exist at process start and never get renamed or deleted. I'm sure that'll be a problem in some obscure case somewhere, but probably not a practical issue :) ChrisA