By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,378 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

Generating .pyo from .py

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.