Compiled version when .cgi extension is used for scripts

Thomas Wouters thomas at xs4all.net
Tue May 16 15:48:47 EDT 2000


On Tue, May 16, 2000 at 06:34:53PM +0200, Bernard Niset wrote:

> Our site is using python extensively and very succesfully. The only thing
> is that I decided to name the cgis script with an extension in .cgi
> instead of .py. The drawback of this decision is that no compiled version
> is generated when a script is executed meaning that it needs a
> recompilation on each execution.

Scripts (the first file you start) are never stored in compiled form. Only
modules you load (files you load with 'import') are stored, always as
'.pyc'. If you want to benifit from this, make your script as lightweight as
possible, putting all or most functionality in a separate module.

Note that your script would have to be fairly lengthy before you to actually
notice the difference between the two versions.

> How can I generate a compiled version of the scripts and how should I name
> them in order for the interpreter to take them into account.

Unfortunately, compiled python scripts need to have the .pyc (or .pyo)
extention for the interpreter to see them as such... If they have any other
name, the python interpreter tries to interpret them as normal scripts
instead. I'm not really sure why, but I guess the variance in bytecode
versions is too great to make the python interpreter autodetect them... I
think it would be neat if it could, though.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list