Python automatically compiles Python source code.To create PYC file manually one can type,
Code:
>> >import <your file name>
In your case ,
Code:
>> >import myprog.py
This will create it’s PYC file in same folder/directory where you have saved the myprog.py file.The major drawback of the above method is that python compiles as well as executes the source code. This would create problems as every time it will execute incomplete source codes.
To avoid this one can try,
import py_compile
py_compile.compile("mymodule.py")
This only compiles the code and does not execute it.
Bookmarks