Python architecture and code execution process

   The overall architecture of python can be divided into three parts: 1. python provides a large number of modules; 2. python provides a large number of libraries; 3. user-defined modules.

 

     The python runtime includes the object/type system, the memory allocator, and runtime state information. The runtime state maintains the actions of the interpreter to switch between different states of executing the bytecode (such as normal state and exception state). It can be It is regarded as a huge and complex finite state machine. The memory allocator is solely responsible for the memory application work when creating objects in python. In fact, it is a layer of interface between python runtime and malloc in C. The object/type The system contains various built-in objects that exist in Python, such as integers, lists, dicts, and various user-defined types and objects.

The core of Python - the interpreter (interpreter) can also be called a virtual machine. In the interpreter, Scanner corresponds to lexical analysis and divides the Python source code input by the file or the code abbreviated by the programmer into a token; Paser corresponds to syntax analysis, Syntax analysis is performed on the analysis results of Scanner, and an abstract syntax tree (AST) is established. The Compiler generates a set of instructions based on the established AST - Python bytecode, and finally Code Evaluator executes these bytecodes. So Code Evaluator Also known as a virtual machine.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325341289&siteId=291194637