Importing something let the Interpreter parse the whole file, translate it into bytecode and then the interpreter is executing the whole file.
In fact if you're using something like:
Only the the function foo is assigned to the name foo, but the function foo can access to everything inside the module util.
The name foo is just a reference to the function foo inside the module util.
If you delete foo the module util, it is not garbage collected, because all modules are cached. If you importing in many different modules the same module again and again, you'll get exactly the same version of the module.
In fact if you're using something like:
from util import fooThe whole file util is imported as module, which lives on the heap (i think so).
Only the the function foo is assigned to the name foo, but the function foo can access to everything inside the module util.
The name foo is just a reference to the function foo inside the module util.
If you delete foo the module util, it is not garbage collected, because all modules are cached. If you importing in many different modules the same module again and again, you'll get exactly the same version of the module.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!