ManderaGeneral/generalimport

Better import handling technique

Mandera opened this issue · 2 comments

Better import handling technique

Current loader idea is to seperate module names based on if they are namespaces or not. This happens immediately, not very efficient because each check requires an import.

It then puts on Importer in the start to handle all namespace imports.
And one at the end to get the rest of the names if the normal importers failed to resolve.

I think a better idea would be to only have one loader in the start which all imports go through.
When an import is made this loader does a new identical import but this next time this loader will ignore it and gets the result of the import if possible.
When it has the "normal" import (still inside the loader method) it can check it:
If it's None or a namespace package then we resolve it to our fake module.

This would be much better and faster if it works, also only requiring one Importer.