Can someone please explain why I would want to only import part of a module instead of all of it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone please explain why I would want to only import part of a module instead of all of it?

23rd Jul 2016, 8:37 PM
Peter Drennan
Peter Drennan - avatar
2 Answers
+ 2
it makes the program run faster since it doesn't have to load all the other functions, and it saves memory since it loads just the ones you need
24th Jul 2016, 3:09 AM
Sean Fessenden
Sean Fessenden - avatar
- 1
Yea.. It's what sean said... . For example.. You need to use only square root fuction from math module... This method will save you some memory and runtime...
27th Jul 2016, 8:06 PM
Prashant Shahi
Prashant Shahi - avatar