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

What does the -O flag do?

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


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