[Tutor] Confused "from module import Name" better than "importmodule"?

Alan G alan.gauld at freenet.co.uk
Mon Jul 11 22:14:18 CEST 2005

> module import name':  is there a performance hit to consider when 
> importing the entire module rather than just getting the specific 
> niceFunction()?  

Not significant. Basically import module puts the module name 
into the local names dictionary. "from m import f" puts f into 
the dictionary, so it could save a dictionary lookup, but they 
are pretty fast...

Its not like the whole module gets copied, it's only a single 
name entry in a dictionary, then an extra dictionary access 
when you use a feature of the imported module.

Alan G.

More information about the Tutor mailing list