Is it possible to fasten the import of cgi?

Cecil Westerhof dummy at dummy.nl
Thu Jan 18 10:16:35 EST 2007


Gabriel Genellina wrote:

> "Cecil Westerhof" <dummy at dummy.nl> escribió en el mensaje
> news:45af6f47$0$322$e4fe514c at news.xs4all.nl...
> 
>>I have a cgi-script dat uses the modules cgi, os, sys and time. Offcourse
>>I
>> can not time the time used to import time, but os and sys do not take
>> more as a millisecond. My script itself takes 3 or 4 milliseconds. But
>> importing
>> cgi takes 95 milliseconds. (This is on my test system a PII 300 MHz. Is
>> there a way to make this more fast? The import off cgi makes the script
>> at least 20 times as slow. Something like mod-python is not a
>> possibility. I could use it on my test machine, but not at the osting
>> provider.
> Surely os was imported earlier, and was already loaded. sys is a builtin
> module. But I think your problem is not how much time takes importing cgi,
> but how much time takes launching a new python process on each request.

Nope, it was certainly cgi. When I fetch time after importing and after the
script finishes, the difference is 4 milliseconds. If I import the modules
apart from cgi after I fetch the first time, there is added about 1
millisecond to the difference. When I also import cgi after taking the
time, the difference grows with 95 milliseconds. So for one reason ore
another, cgi is very expensive.




More information about the Python-list mailing list