Python - Compiling Python code from py to pyc

Although Python script does not need to be explicitly compiled before running them, it is possible to manually compile them into bytes code (.pyc) from the script (.py) for better efficiency.

You can read http://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm to know more about compiling a Python code from py to pyc

Or, you can use the following command to compile a Python source file.

python -c "import py_compile; py_compile.compile('test.py', 'test.pyc')"



Comments

Popular Posts