Preparations for analyzing Python source code and analyzing python source code
A Python developer is also a C language enthusiast. In order to enhance his understanding of the Python language implementation, I recently chose to read Chen Ru's book, read Python3.5.1 source code, and record the Reading Notes again.
I. Overall Python Structure
Python is divided into three parts: File Groups, Interpreter, and Runtim Environement ):
The file system is used to store Python script files (. py). It consists of built-in modules, third-party modules, and user-defined modules;
The interpreter is used to scan, parse, compile, and run Python script files. It consists of four parts: Parser, Parser, Complier, and Exauator;
1. Renewal
It is used for lexical parsing of Python scripts and divides scripts into tokens.
2. Parser
Parse all tokens to create an abstract syntax tree.
3. Complier
Create a command set (Python bytecode) based on the abstract syntax tree)
4. Exauator
Run Python bytecode
Ii. runtime environment mainly includes Object/type system, memory distributor, and runtime status information
1. Object/Type System
Contains all built-in Python objects, user-defined types, and objects
2. Memory distributor
Maintains the memory application for Python object creation.
3. Running status information
Maintenance interpreter switches between different statuses during bytecode execution
Iii. Overall Structure: