A simple explanation of why is that import statements include two operations: loading a module (i.e., running code inside it) and importing names into the namespace of the import module. Re-import only repeats the second operation. The reason is that the first operation can be costly in terms of computing and memory resources.
reload provided as a way to repeat the first operation, but as you have seen, this requires a module name. However, do not be fooled into thinking that from foo import bar does not load the entire module. It does. All module code is running, you can just look at the names (for example, bar ) that you explicitly import. For this reason, there is a slight difference between importing a module, rather than importing; the only differences are namespace problems. Therefore, if you think you can reload the foo module, you should go ahead and make import foo . If you want, you can do this to update the imported names:
import foo from foo import bar
There is another reason you cannot reimport individual names, which means that Python has no way to change the objects referenced; he can only rename names. Suppose you did this:
from foo import bar newBar = bar from foo import bar
Even if the second import really updated the value of bar, it will never be able to update the value of newBar, because neither foo nor bar have any way of knowing that you created an additional name to refer to bar. Avoiding rewriting individual names prevents you from falling into this trap; if people thought that re-importing would update names, it would be easy to forget that it would not update objects anyway.
source share