Compiled version when .cgi extension is used for scripts

Thomas Wouters thomas at xs4all.net
Wed May 17 03:16:50 EDT 2000


On Tue, May 16, 2000 at 10:42:18PM +0200, Bernard Niset wrote:

> > 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.

Useless, probably, slower, maybe, but is the minor speedup really worth
having to check wether the code should be recompiled, dumping the new
compiled version to disk, not to mention the clutter it would cause, having
all those .pyc files lying around ? If you really need the speedup, create a
C wrapper that exec()'s python with 'argv[0] + ".pyc"' as argument, and only
update the bytecode version when you want to.

But dont forget to recompile the compiled version when you install Python
1.6, or it wont work :-)


> > 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.

Yes, I know, but my point was that you can't rename your '.pyc' file to
something without a .pyc extention, and still keep it functional. If you
want to pass a bytecode-compiled version of a script to the python
interpreter, it *has* to have a name ending on '.pyc'. If this wasn't
necessary, you could make a 'misc binary' handler on linux that allows you
to run python bytecode as if they were normal binaries ;-)

-- 
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