Thursday, August 28, 2014

Compile Python script to pyc

To compile a .py file to .pyc you can use the py_compile library. The following will create pyc compiled files from py source.

>>> import py_compile
>>> py_compile.compile('script.py')

One important thing to note is that compiling to .pyc extension only improves the speed in which the files are loaded, no change happens on their execution speed.

The documentation on this module can be found here. Another library for compiling python files is compileall, and its documentation is here.

No comments:

Post a Comment