If I import a module that was already imported before in a parent module, will it impact load time again or will it be negligible ? (in python 3)
To illustrate, let's say I have modules like these:
module_0.py
module_1.py
module_2.py
module_0.py, module_1.py, module_2.py are imported without side-effects.
In module_0:
[100000 code lines then]
CONSTANT_A = 0
CONSTANT_B = 0
In module_1:
from module_0 import CONSTANT_A
CONSTANT_C = 0
In module 2:
from module_0 import CONSTANT_B
from module_1 import CONSTANT_C
If I run module_2
I have an import of module_0
inside module_1
and inside module_2
Modules import impact startup performance as described in Do unused imports in Python hamper performance?
Will the startup performance be impacted twice in this case ? Or will the imported module_0
be sort of "in python's memory" from the first import and the second load of the same module_0
in another module be negligible ?
(I know that having 100k lines of code in a single module is bad practice, this is for the sake of the example)