Explicit or general importing of namespaces?

Michael Hoffman cam.ac.uk at mh391.invalid
Mon Feb 28 06:09:55 EST 2005


Diez B. Roggisch wrote:
 >[Harlin Seritt]:
>>Is there really a major performance difference between doing the
> 
> No.

Actually, if you are using a name in another module repeatedly
in an inner loop, it can make a big difference if you have to lookup
the name in the module repeatedly. In that case, just explicitly
import the name you want to use repeatedly:

from Tkinter import Label, otherfunction, othervariable

Of course, you are not likely to see this use case when you're doing
UI programming.

But don't do "from Tkinter import *" for the reasons Diez has
identified in the FAQ.
-- 
Michael Hoffman



More information about the Python-list mailing list