[Python-ideas] Refactoring the import system to be object-oriented at the top level
Mathias Panzenböck
grosser.meister.morti at gmx.net
Sun Nov 8 11:19:00 CET 2009
Sounds like the ClassLoader in Java. I think it would be a good idea.
On 11/08/2009 05:24 AM, Nick Coghlan wrote:
> ...
> Anyway, the gist of the idea in the subject line is to take all of the
> PEP 302 data stores and make them attributes of an ImportEngine class.
> This would affect at least:
>
> sys.modules
> sys.path
> sys.path_hooks
> sys.path_importer_cache
> sys.meta_path
> sys.dont_write_bytecode
>
> The underlying import machinery would migrate to instance methods of the
> new class.
>
> The standard import engine instance would be stored in a new sys module
> attribute (e.g. 'sys.import_engine'). For backwards compatibility, the
> existing sys attributes would remain as references to the relevant
> instance attributes of the standard engine.
>
> Modules would get a new special attribute (e.g. '__import_engine__')
> identifying the import engine that was used to import that module.
> __import__ would be modified to take the new special attribute into account.
> ...
More information about the Python-ideas
mailing list