469,284 Members | 2,443 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

What does the -O flag do?

http://rgruet.free.fr/PQR25/PQR2.5.html says

"Optimize generated bytecode (also PYTHONOPTIMIZE=x). Asserts are
suppressed."

Is removing asserts all it does, where can I find more details? I'm
guessing it's not very useful as I hardly ever see it mentioned.

Jan 9 '07 #1
1 2810
Sard schrieb:
"Optimize generated bytecode (also PYTHONOPTIMIZE=x). Asserts are
suppressed."

Is removing asserts all it does, where can I find more details? I'm
guessing it's not very useful as I hardly ever see it mentioned.
It somewhat depends on the Python version. To find out precisely what
it does, search the source code for Py_OptimizeFlag. In 2.5, it

- causes the interpreter to load .pyo files, not .pyc files
(in .zip files, just makes .pyo preferred over .pyc)
- causes __debug__ to have a value of 0
- ignores assert statements in source code
- treats __debug__ statically as being 0
- causes the byte code generator to save .pyo files, not .pyc

HTH,
Martin
Jan 9 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

92 posts views Thread by Reed L. O'Brien | last post: by
6 posts views Thread by Niklaus | last post: by
8 posts views Thread by xanthviper | last post: by
39 posts views Thread by windandwaves | last post: by
1 post views Thread by Gary Wessle | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.