Generating .pyo from .py

Discussion in 'Python' started by skn, Jun 16, 2005.

  1. skn

    skn Guest

    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
     
    skn, Jun 16, 2005
    #1
    1. Advertisements

  2. skn

    Maurice LING Guest

    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
     
    Maurice LING, Jun 16, 2005
    #2
    1. Advertisements

  3. 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
     
    Leif K-Brooks, Jun 16, 2005
    #3
  4. skn

    skn Guest

    Thanks a lot !!
    It works fine !!

    regards,
    skn

     
    skn, Jun 20, 2005
    #4
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.