Basic import Questions (with bonus profiling question)

Gregory Piñero gregpinero at gmail.com
Thu Aug 31 11:49:27 EDT 2006


Hey Folks,

Some import questions that a search didn't turn up for me.

1. Will "from somemodule import onething" take as long to start up as
import somemodule?
2. Is there anyway I can get at onething more quickly?
3. If I put an import statement hidden away in some function, will
Python only do the import when that function is called?  If I say,
never use that function would that import statement affect performance
at all?

Ultimately I have IIS running python as a CGI script and it seems to
just be taking many seconds to load a small page.  I'm guessing the
issue is starting up the interpreter and loading all the modules.

BTW I know it would be better to profile the code but how do you
profile a CGI script?  I can't just pass it CGI parameters can I?  And
does profiling take into account the time of loading modules?

Thanks,

-Greg Pinero



More information about the Python-list mailing list