[Python-checkins] r52292 - sandbox/trunk/import_in_py/importer.py

Nick Coghlan ncoghlan at gmail.com
Fri Oct 13 10:59:41 CEST 2006


Brett Cannon wrote:
>     Having __import__ always generate the module would make it harder to
>     use things that aren't really modules.  (examples:  A module with a
>     custom __dict__ type that gripes at external modification; the
>     forwarders used when a module changes its name; Lazy Importers) 
> 
> 
> Good point.  Question is whether these use-cases will occur enough to 
> make it worth it.  We can either lean towards hyper-generalization or 
> try to minimize what the importer/loaders have to do.

Go with the generalization - there are existing application toolkits like PEAK 
that use lazy importing to avoid slowing startup to a crawl (by deferring the 
actual import until the first time someone attempts to access the module's 
namespace).

The minimisation of what importers/loaders have to do can be handled the same 
you're handling it for your code - by providing pluggable base classes that 
delegate to internal methods.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-checkins mailing list