473,569 Members | 3,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it possible to fasten the import of cgi?

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.

Jan 18 '07 #1
11 1878
Cecil Westerhof wrote:
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.
Does the hosting provider support fastcgi? It would avoid starting the
interpreter at each request too.

Jan 18 '07 #2
Daniele Varrazzo wrote:
Cecil Westerhof wrote:
>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.

Does the hosting provider support fastcgi? It would avoid starting the
interpreter at each request too.
I am afraid not. It is very bare bone. Also they do not really support
python. (When they had a problem, perl and bash scripts worked within a
day, python scripts had to wait for one and a halve week.)

I am thinking about switching my provider. What are important things to keep
in mind when selecting another one?

Jan 18 '07 #3
"Cecil Westerhof" <du***@dummy.nl escribió en el mensaje
news:45******** *************@n ews.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.

--
Gabriel Genellina
Jan 18 '07 #4
Gabriel Genellina wrote:
"Cecil Westerhof" <du***@dummy.nl escribió en el mensaje
news:45******** *************@n ews.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.

Jan 18 '07 #5
"Cecil Westerhof" <du***@dummy.nl escribió en el mensaje
news:45******** *************@n ews.xs4all.nl.. .
Gabriel Genellina wrote:
>"Cecil Westerhof" <du***@dummy.nl escribió en el mensaje
news:45******* **************@ 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.
I'll try to explain better: the cgi *protocol* (I'm not talking about the
cgi *module*) requires a *new* python process to be created on *each*
request. Try to measure the time it takes to launch Python, that is, the
time from when you type `python ENTER` on your shell and the interpreter
prompt appears. That time is wasted for *every* cgi request, and I bet it is
much greater than the 95 ms you measure importing a module (be it cgi or
whatever). You'll gain much more responsiveness if you can switch to another
protocol, be it FastCGI, WSGI, mod_python or another.

Anyway, comparing the import time between os, sys, and cgi is not very
meaningful. sys is a builtin module, so "import sys" does very little. os is
likely to be already imported by the time your script begins, so "import os"
just verifies that os is already in sys.modules. "import cgi" is the only
example when Python actually has to load something, so it's not a surprise
if it takes longer.

--
Gabriel Genellina
Jan 18 '07 #6
Cecil Westerhof <du***@dummy.nl wrote:
>
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.
Realistically, do you plan to support more than a few dozen requests per
minute? If not, then it doesn't matter at all. The script launch overhead
is an insignificant part of the user's browser experience.

If you do expect a hundred requests per minute, then CGI is not an
appropriate choice. You either need to switch to a one of the web
frameworks (like CherryPy or Django or WebWare or one of the hundreds of
others), or <gackmove to PHP.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 19 '07 #7
On 1/18/07, Cecil Westerhof <du***@dummy.nl wrote:
I have a cgi-script dat uses the modules cgi, os, sys and time. OffcourseI
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.
Maybe python-launcher-daemon can help you?
http://blogs.gnome.org/view/johan/2007/01/18/0 But if you can not use
mod_python then you probably can not use any long running processes
either.

--
mvh Björn
Jan 19 '07 #8
BJörn Lindqvist wrote:
On 1/18/07, Cecil Westerhof <du***@dummy.nl wrote:
>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.

Maybe python-launcher-daemon can help you?
http://blogs.gnome.org/view/johan/2007/01/18/0 But if you can not use
mod_python then you probably can not use any long running processes
either.
By my current provider I can not use this. But I am going to look for
another. What are the pro's en cons off the different systems? FastCGI,
PyApache, mod_pythion and maybe others I am not aware off.

Jan 19 '07 #9
Tim Roberts wrote:
Cecil Westerhof <du***@dummy.nl wrote:
>>
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.

Realistically, do you plan to support more than a few dozen requests per
minute? If not, then it doesn't matter at all. The script launch
overhead is an insignificant part of the user's browser experience.
Not at the moment. The application is in alpha, so it is mostly a few
testers. At the moment it is going life I want to have another provider.
So I have a little time to search for another provider and select 'the best'
framework. ;-}

Jan 19 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1816
by: Carol Carrot | last post by:
Greetings. I've never seen a more complicated, verbose pile of hogwash than the "deliverd by mailman" mailing list program. Still I have to use it. I'm trying to get a header to get attached tot he email. it gets stripped from the email, whwere as the footer comes in as an attachment.
1
4239
by: Fadly Tabrani | last post by:
Hi guys, This is the first time I'm posting to the newsgroup, hope you can help out. I'm writing a module to interface with the task scheduler in windows using PyWin32. Everything has been great so far but I'm stuck on displaying the propertys page of a task. Here's the code: import pythoncom import win32api
10
1912
by: Steven Reddie | last post by:
Hi, I want to do something like the following, which doesn't work: modulename = 'module' import modulename The error is that there is no module named 'modulename'. Is there a way to get that variable expanded?
4
39720
by: g | last post by:
I'd like to have a CSS file for everything that's common to my site, and other CSS files that are specific to certain pages or groups of pages. When a page loads, it would load in BOTH the General CSS and the specific CSS file for that page. As long as none of the selector names were the same on both, could the page follow the styles set out...
29
1727
by: Tuvas | last post by:
I have a function in a program that works something like this. def load_pic_data(width,heigth,inpdat, filt=TRUE): data='' total=0 tnum=0 size=100 for y in range(0,heigth): row='' for x in range(0,width):
5
2412
by: Dara Durum | last post by:
Hi ! I want to create a Process Pool Object. I can hold started processes, and can communicate with them. I tryed with many ipc methods, but every of them have bug or other problem. Sockets are unavailabe (because Windows Firewall hold them). I think I will use pipe.
0
2369
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr = 1) br.select_form(name="foo") br.select_form(name=foo) br.select_form(name="foo")
3
1251
by: Steven W. Orr | last post by:
This is all an intro learning experience for me, so please feel free to explain why what I'm trying to do is not a good idea. In the Cookbook, they have a recipe for how to create global constants. ----------------- class _const: class ConstError(TypeError): pass def __setattr__(self,name,value): if self.__dict__.has_key(name):
12
7918
by: Chris Allen | last post by:
Hello fellow pythoneers. I'm stumped on something, and I was hoping maybe someone in here would have an elegant solution to my problem. This is the first time I've played around with packages, so I'm probably misunderstanding something here... Here's what I'd like to do in my package. I want my package to use a configuration file, and...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.