How to compile a python script to *.pyo

Peter Hansen peter at engcorp.com
Wed Apr 2 23:18:50 CEST 2003


Philippe Lafoucrière wrote:
> 
> danny at iamlearning.com wrote:
> 
> > I'm new on this, please bear with we.
> >
> > Let's say I have this script:
> >
> > --------------------------
> > #!/usr/bin/env python
> > x = 'Hello Python'
> >
> > print x,
> >
> > --------------------------
> >
> > How can I compile this script to *.pyo?
> >
> > Thanks in advance,
> >
> > Danny
> 
> python -O yourscript.py

Generally this doesn't work.  You have to import
a module (or use other techniques) for it to be compiled.
Python does not store a .pyc or .pyo file for the main 
module, perhaps surprisingly.

-Peter




More information about the Python-list mailing list