The path of Python-pyc

Source: Internet
Author: User

I. Explanatory language and compiled language

Explanatory language: Before the program executes, the program executes a compilation process through the compiler, transforming the program into machine language. The runtime does not need to be translated and executes directly. The most typical example is the C language.

Compiled language: Without the process of compiling, but when the program is running, through the interpreter to the program to explain the line, and then run directly, the most typical example is Ruby.

Summary: Because the compiler language in the program before the program has already made a "translation", so at run time there is less "translation" process, so the efficiency is higher. However, we cannot generalize that some explanatory language can be optimized for the whole program by the interpreter's optimization, which is more efficient than the compiled language.

In addition, with the rise of virtual machine-based languages such as Java, we cannot divide the language into two purely interpretative and compiled types. In Java, for example, Java is first compiled into a bytecode file by a compiler and then interpreted as a machine file by the interpreter at run time. So we say that Java is a language that is compiled and interpreted first.

Second, Python's running process

Pycodeobject and PYc files

Pycodeobject is the result that the Python compiler actually compiles.

When the Python program runs, the result of the compilation is saved in the Pycodeobject in memory, and when the Python program finishes running, the Python interpreter writes Pycodeobject back to the PYc file.

When the Python program runs for the second time, the program will first look for the PYc file on the hard disk, and if it is found, load it directly or repeat the process.

So we should be able to locate Pycodeobject and pyc files, we say that PYc file is actually a kind of persistent saving way of pycodeobject.

PYC: Pre-compiled byte-code file, not machine code

The path of Python-pyc

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.