Wednesday, June 15, 2011

So after two weeks of preparations, I spent last week migrating the core importing functionality to ImportEngine.

Since there the hierarchy of classes in importlib involved in __import__ functionality has to be pretty deep to maximise code reuse, the changes are spread over quite a few places:

  • @module_for_loader
  • BuiltinImporter.find_module
  • BuiltinImporter.load_module
  • FrozenImporter.find_module
  • FrozenImporter.load_module
  • _LoaderBasics._load_module
  • _SourcelessFileLoader.load_module
  • _ExtensionFileLoader.load_module
  • PathFinder._path_hooks
  • PathFinder._path_importer_cache
  • PathFinder.find_module
  • _FileFinder.find_module
  • _DefaultPathFinder._path_hooks
In short, the engine argument has to be passed from the __import__ function down to the loaders. This is particularly tricky in case of path hooks (which are in fact implemented as a meta hook). All this results in substantial changes in the code and there are still a few places I need to iron out, and afterwards it will need solid testing.

No comments:

Post a Comment