What does the -O flag do?

Discussion in 'Python' started by Sard, Jan 9, 2007.

  1. Sard

    Sard Guest

    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.
    Sard, Jan 9, 2007
    #1
    1. Advertising

  2. 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
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Jan 9, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. valentin tihomirov

    defining a flag-dependent constant

    valentin tihomirov, Nov 25, 2004, in forum: VHDL
    Replies:
    3
    Views:
    509
    Jim Lewis
    Nov 28, 2004
  2. Replies:
    6
    Views:
    386
    Jim Cheshire [MSFT]
    Dec 17, 2003
  3. Dirk Gomez

    -server flag: what does it do?

    Dirk Gomez, Apr 27, 2006, in forum: Java
    Replies:
    1
    Views:
    3,246
    Remon van Vliet
    Apr 27, 2006
  4. Gianni Galore
    Replies:
    0
    Views:
    1,253
    Gianni Galore
    Sep 8, 2010
  5. Terry
    Replies:
    2
    Views:
    397
    Terry
    Jul 3, 2011
Loading...

Share This Page