File types in Python

Source: Internet
Author: User
Tags virtual environment

There are 3 types of Python files: source code files, compiled files, optimized files.

Source code files: Files that end with ". Py" for code saved for the development program.

Compile file: The file ends with ". PYc", assuming that the source file is 1.py, if 1.py is compiled to 1.PYC, enter the following code in 2.py:

#!/usr/bin/python3import py_compilepy_compile.compile (' 1.py ')

Then on the command line:


Can. Since I am using the enve virtual environment, the compiled PYC file is under the __python__ folder.

Optimized code: Optimized source file with extension ". Pyo", Python-o-M py_compile 1.py.

The code that is compiled and optimized executes faster than the source file interpretation, and when necessary, the source code can be compiled or optimized for execution.

Generally in the development process, with. PY development will be easy to debug, development.

File types in Python

Related Article

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.