How Python Works

Source: Internet
Author: User

1. Operation Process

The Python source program is run, not directly to the machine to run, but first to the Python virtual machine (through the C language), and then interpreted by the Python virtual machine as a machine-readable instruction to run;--so Python is an interpreted or dynamic language

The role of 2..PYC files

The. pyc file is a Python-aware bytecode file generated by the Python source program when interacting with a Python virtual machine, and then the Python virtual machine interprets it as a machine-readable instruction; ——. The PYc file is a Python virtual machine-readable bytecode file that is translated into Python source code

3. Why does the Python program run directly do not see the. pyc file, and the import module will see the generated. pyc file?

Here comes a caching mechanism, Directly running the Python program will also generate. pyc files, but not save, Python virtual machine will directly run the program as a long-running program, do not need to be called frequently, and import the module is considered to be frequently called, so when the module is imported, the next time you import the module, you will see if there is. P YC file, if any, import the. pyc file directly, or if not, transcode the module to a bytecode file PYc, and then import the bytecode file. This will involve the problem of module modification, if the module is modified, the virtual opportunity automatically detects the modification time of the module program, and if it is modified, the bytecode file is regenerated.

How Python Works

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.