Compiled version when .cgi extension is used for scripts

Bernard Niset bn at 7ways.com
Tue May 16 16:39:20 EDT 2000


"Thomas Wouters" <thomas at xs4all.net> wrote in message
news:20000516214847.Y13281 at xs4all.nl...
> 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.
>
I know, pretty much of the functionnality is in .py module that is used as a
library through out the website.

> Note that your script would have to be fairly lengthy before you to
actually
> notice the difference between the two versions.
I know but it is still useless to to a compilation each time.
>
> > 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.
When the script is named differently from .py, the interpreter could use
scheme like original_name.ext.pyc.
>
> --
> Thomas Wouters <thomas at xs4all.net>
>
> Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
>
Thanks by the way.






More information about the Python-list mailing list