+ 1
What's the difference between 'import module' and 'from module import ...' considering performance?
What is recommended? Which one should be used more often? What does it depend on? How to decide...
3 Answers
+ 1
The difference is that "from <module/file> import <class/module>" is used for importing some specific thing from that file/module. In the other hand "Import<module> is used for importing the whole module/file.
+ 1
Thanks Aryan Sarpal, but what I meant is how it impacts the performance of the program. Do you know?
Edit: I assume that if you use huge modules, it's better to avoid loading them all into the program. But I'm not sure, so I asked
+ 1
Hi Orville Vroemen,
the performance will impact while running the file but it might be that when you are using the "from import" one the class/module you are importing might be that it needs the whole module to run that part of the module. So it matters where and when you need what.