469,626 Members | 1,025 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Generating .pyo from .py

skn
Hello.,

Does the python compiler provide an option to generate a .pyo(optimized byte
code file) from a .py (source file)?

For generating .pyc I know that I only have to pass the source file name as
an argument to py_compile.py.
But for generating .pyo, I could not find anything.

Any clues/help will be greatly appreciated.

With best regards,
skn
Jul 19 '05 #1
3 8990
say your code is "test.py" and you usually run it as "python test.py",
then the "-O" option will generate .pyo files.
That is "python -O test.py"

Cheers maurice

skn wrote:
Hello.,

Does the python compiler provide an option to generate a .pyo(optimized byte
code file) from a .py (source file)?

For generating .pyc I know that I only have to pass the source file name as
an argument to py_compile.py.
But for generating .pyo, I could not find anything.

Any clues/help will be greatly appreciated.

With best regards,
skn

Jul 19 '05 #2
skn wrote:
Does the python compiler provide an option to generate a .pyo(optimized byte
code file) from a .py (source file)?

For generating .pyc I know that I only have to pass the source file name as
an argument to py_compile.py.


py_compile.py checks __debug__ to decide whether to use optimize mode,
and the -O option to Python turns __debug__ off, so:

python -O py_compile.py foo.py
Jul 19 '05 #3
skn
Thanks a lot !!
It works fine !!

regards,
skn

"Leif K-Brooks" <eu*****@ecritters.biz> wrote in message
news:JV*****************@monger.newsread.com...
skn wrote:
Does the python compiler provide an option to generate a .pyo(optimized byte code file) from a .py (source file)?

For generating .pyc I know that I only have to pass the source file name as an argument to py_compile.py.


py_compile.py checks __debug__ to decide whether to use optimize mode,
and the -O option to Python turns __debug__ off, so:

python -O py_compile.py foo.py

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by paul | last post: by
reply views Thread by Dan Gass | last post: by
17 posts views Thread by flupke | last post: by
3 posts views Thread by Raed Sawalha | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.