Preparation of Python source code profiling

Source: Internet
Author: User
Tags python script

A Python program developer, is also a C language enthusiast, in order to strengthen their understanding of the Python language implementation, recently chose to read under the Chen Ru Teacher's book, read the Python3.5.1 source code, and then record the reading notes.

First, the overall structure of Python

PYthon is generally divided into three parts: File system (Files Groups), interpreter (interpreter), Runtime Environment (Runtim environement):

The file system is used to store Python script files (. py), mainly divided into built-in modules, third-party modules, user-defined modules;

The interpreter is used to scan, parse, compile and run the Python script file, mainly divided into scanner, Parser, Complier, exauator four parts;

1, Scanner
Used for lexical parsing of Python scripts, splitting the script into tokens

2, Parser
Syntax parsing of all tokens, creating an abstract syntax tree

3, Complier

Create a collection of instructions (Python bytecode) based on an abstract syntax tree

4, Exauator

Run Python bytecode

Second, the runtime environment is mainly divided into object/type system, memory allocator, run-time state information

1. Object/Type System

Contains all built-in objects for Python, user-defined types, and objects

2. Memory Splitter
Responsible for maintaining the memory request when the Python object is created

3. Run-time status information
Responsible for maintaining the interpreter switching actions between different states when executing byte codes

Third, the overall structure diagram:

Preparation of Python source code profiling

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.