module is not found in sys.modules, then Python’s import protocol is invoked to find and load the module. - This protocol consists of two conceptual objects, finders and loaders. - A finder’s job is to determine whether it can find the named module using whatever strategy it knows about. - Loader’s job is to load the module (execute the code in the module and register the globals) - Objects that implement both of these interfaces are referred to as importers.
to implement a method called find_spec which returns a ModuleSpec. This ModuleSpec object is used to encapsulate all import-related information (what the name is and which loader instance to use to load it) - Loader objects need to implement a method called exec_module which just fetches and executes the code in the module and binds it to the namespace of the module name. - If you want to make the same object as a finder and loader, you will need to define another method called create_module.