I just wanted to ask whether all modules imported with an import statement in java and python are loaded into memory at runtime, even if they are not used in the program. I asked somebody and they told me in java, only the ones that are actually used are loaded into RAM at runtime and in python, all imported modules are always loaded into RAM at runtime whether you use them or not. Is this true? If yes, does this make python less efficient in memory usage at least in this sense (disregarding other aspects like garbage collection or the workings of the JVM, etc)?
Sorry for the superfluous words. Just want to be clear- The person I asked told me in java, only the ones that are actually used are loaded into RAM at runtime because during compilation the import statements only act as references to the actual packages, and the JVM loads them into memory only if the references are actually used, and in python, all imported modules are always loaded into RAM at runtime whether you use them or not (by loading they mean, that all definitions, functions and objects of that package/module are loaded into memory during runtime whether or not they are used), since they're not just references rather are actual instructions to load them into memory in python. I need guidance on this. Thanks.
Edit- I am aware that most programs only import the things they need but if suppose a program in java and one in python are there are both import 3 similarly sized packages but use only one of them, which one will use more memory solely on that basis?