If you use Python -OO is it a permanent condition??

Jeff Sasmor jeff at sasmor.com
Mon Jun 17 14:32:55 EDT 2002


I tried to find an answer to this in the comp.lang.python archives
on google, but could only find vague references:

I have an app that works fine until I run compileall on it when
Python is run with the -OO flag, e.g.,

python -OO makedist.py

where part of makedist.py has

compileall.compile_dir('.',20,force=1)


I then take all the .pyo files and put them in a different
directory; I'm trying to make a smaller distribution and was
trying this out as an option.

The only problem is that when I run this application that is
only .pyo files,  imports do not work:

python P1.pyo  (this is the entry point)

produces errors at the first import:

Traceback (most recent call last):
  File ".\P1.py", line 132, in ?
ImportError: No module named plat_init

So  I tried:

python -OO P1.pyo

and it works just fine.  Does this mean that the interpreter must always
be started with -OO to execute files compiled with -OO?  I can't imagine
why this would be the case, but it seems to be -- at least as far as I can
see
from my little bit of experimentation.

My app uses the 'compile' built-in within it; as the interpreter is running
with the -OO flag it would seem that what I compile would be compiled
that way too - no good for what I'm trying to do.

Can some expert in the deep innards of Python-dom comment on this
and help clarify this for me?

TIA,

Jeff Sasmor
jeff at sasmor.com





More information about the Python-list mailing list