Under Python compile py into PYc and PYO

Source: Internet
Author: User

Use
Python-m Py_compile file.py

Python-m py_compile/root/src/{file1,file2}.py
Compiled into a pyc file.
You can also write a script to do the job:
Code:


Import Py_compile
Py_compile.compile (' path ')//path is the path that includes the. py file name

Use
Python-o-M Py_compile file.py

Compiled into a pyo file.
1. The-M is equivalent to the import in the script, where the-M py_compile is equivalent to the import py_compile
2.-o If you change to-oo is to delete the corresponding pyo file, specific help can be entered in the console python-h view

What is a PYc file

PYC is a binary file, which is generated by the py file after compiling, is a byte code,py file becomes PYc file, the speed of loading is increased, and PYC is a cross-platform bytecode, is executed by Python virtual machine, This is the concept of a virtual machine similar to Java or. Net. PYC content, is related to Python version, the different version of the compiled PYc file is different, 2.5 compiled PYC files, 2.4 version of Python is not executable.

What is a pyo file

PYO is an optimized compiled program Python-o source file to compile the source program into a pyo file

What is a PYD file

PYD is a dynamic link library for Python.

Under Python compile py into PYc and PYO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.