Compiling a Python File on Mac OS X Tiger

A

Asad Habib

Hello. I am working on Tiger and wanted to find out how to compile a
Python (.py) file into a .pyc file and then into a .pyo file. Can the
compilation be achieved within the interpreter? Also, I am
new to Python and wanted to know the difference between .pyc and .pyo
files. Is this comparison similar to C? Any help would be appreciated.
Thanks.

- Asad
 
J

Jacob Page

Asad said:
Hello. I am working on Tiger and wanted to find out how to compile a
Python (.py) file into a .pyc file and then into a .pyo file. Can the
compilation be achieved within the interpreter? Also, I am
new to Python and wanted to know the difference between .pyc and .pyo
files. Is this comparison similar to C? Any help would be appreciated.
Thanks.

http://www.network-theory.co.uk/docs/pytut/tut_48.html has some good
explanations. To generate the .pyo files from the interpreter, add the
-O option.

The difference between .pyc and .pyo files is that .pyo files are
optimized a bit; for example docstrings are removed (which will break
pydoc tests). According to the above link, .pyo files don't run any
faster; they just load faster.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top