On Mon, Dec 29, 2014 at 08:39:41AM -0800, Rick Johnson wrote:
On Monday, December 29, 2014 8:12:49 AM UTC-6, Steven D'Aprano wrote:
I just threw this lazy import proxy object together. I haven't tested it
extensively, but it seems to work:
[...]
All you've done is to replace "import decimal" with "decimal = lazy_import('decimal')" -- what's the advantage?
It delays the actual import of the module until you try to use it. 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. Personally, I have no use for this, but people have been talking about lazy importing recently, and I wanted to see how hard it would be to do. -- Steven