[Python-ideas] Provide a way to import module without exec body
Nick Coghlan
ncoghlan at gmail.com
Fri Dec 1 05:36:18 EST 2017
More information about the Python-ideas mailing list
Fri Dec 1 05:36:18 EST 2017
- Previous message (by thread): [Python-ideas] Provide a way to import module without exec body
- Next message (by thread): [Python-ideas] Provide a way to import module without exec body
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 1 December 2017 at 20:17, Steven D'Aprano <steve at pearwood.info> wrote: > If that's what you mean, then no, I haven't wished for that. Unless I'm > missing something, it seems pointless. When, and why, would I want to > import an empty module? Having access to something along these lines is the core building block for lazy loading. You figure out everything you need to actually load the module up front (so you still get an immediate ImportError if the module doesn't even exist), but then defer actually finishing the load to the first __getattr__ invocation (so if you never actually use the module, you avoid any transitive imports, as well as any other costs of initialising it). Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message (by thread): [Python-ideas] Provide a way to import module without exec body
- Next message (by thread): [Python-ideas] Provide a way to import module without exec body
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list