Python modules

zoom zoom at yahoo.com
Mon Jan 14 09:54:27 EST 2013


Is there any "rules" regarding importing python modules within your own 
module? I mean, how does this affects the performance of the program?

For example, I have my own module named "sound".
At the top of the file sound.py I have:
import scipy

In the code I have:
import scipy, sound, etc

Now I have two instances of every function within scipy, e.g.
scipy.r_[a] = sound.scipy.r_[a]

Module importing is quite fast, but not instant. It takes some time, but 
it happens only once. My concern is whether I hold all these multiple 
instances of same function in the memory, and does this reduce the 
performance of my program.

In short, when creating a module, is it worthwhile to be careful and 
import only necessary functions, nothing more?



More information about the Python-list mailing list