9 ms·
Python imports aren't necessarily always importing Python source code -- they can be pyc (bytecode) files, or C API extensions, etc. These are slightly more co
by __float 5y ago
Python imports aren't necessarily always importing Python source code -- they can be pyc (bytecode) files, or C API extensions, etc.
These are slightly more complicated than "load the script at this path".
There's probably a more detailed answer, in that historically, decisions were made that we're now stuck with. Python packages can and sometimes intentionally have import-time side effects, for example. They must be only run once, without relying on convention, or we break existing code.