In java, the import statements themselves do not load anything into memory. They are just references to classes or packages that the Java compiler and the JVM will use to resolve class names. The actual loading of classes happens during runtime when those classes are needed
In python, when you import a module, the entire module is loaded into memory at runtime. This means that even if you import a module but never actually use it, Python will still load the module into memory, which includes all definitions, functions, and objects in that module.
In terms of memory efficiency, this does make Python less efficient in this specific context, because Python will allocate memory for entire modules that might not even be needed.
About your last question Python will still load all 3 packages into memory, whereas Java will only load the package that you actually use.