Python Source Code Anatomy
Python source code analysis PDF hd | baidu cloud disk | free download address
Decompression code: 1024
Content Introduction
As a mainstream dynamic language, Python is not only easy to learn and portable, but also has a powerful and rich library support. In addition, Python’s powerful extensibility makes it very easy for developers to use C/C++ to write Python extension modules, but also to embed Python in C/C++ programs, adding dynamic extension and dynamic programming capabilities to their systems. .
To make the most of the Python language, it is important to have a deep understanding of how Python works, both by itself and interactively with C/C++. This book takes CPython as the research object and dissects Python implementation in depth and detail at the C code level. Not only does the book cover the anatomy of a large number of Python built-in objects, but it also departs much of the book to the Anatomy of the Python virtual machine and Python’s advanced features. Through this book, readers will be able to thoroughly understand the operation principle of Python’s core technologies such as general expressions, control structure, exception mechanism, class mechanism, multi-threading mechanism, dynamic loading mechanism of modules, memory management mechanism and so on. Meanwhile, the core technologies of dynamic languages revealed in this book are useful for understanding other dynamic languages. Such as Javascript, Ruby and so on also have great reference value. .
This book is for Python programmers, dynamic language enthusiasts, and C programmers
Catalogue
Chapter 0 Python source code anatomy — Compiling Python
0.1 Overall Python architecture
0.2 Organization of Python source code
Compiling Python in 0.3 Windows
0.4 Compiling Python in Unix/Linux
0.5 Modify the Python source code
0.6 The Path to Python
0.7 Some precautions
Part 1: Python built-in objects
Chapter 1 an Introduction to Python objects
1.1 Objects in Python
1.2 Type Objects
1.3 Polymorphism of Python objects
1.4 Reference Counting
1.5 Classification of Python Objects
Chapter 2. Integer objects in Python
2.1 Introduction to PyIntObject
2.2 Creation and maintenance of PyIntObject objects
2.3 Hack PyIntObject
Chapter 3. String objects in Python
3.1 PyStringObject与PyString_Type
3.2 Creating a PyStringObject object
3.3 Intern mechanism for string objects
3.4 Character buffer pools
3.5 PyStringObject efficiency issues
3.6 Hack PyStringObject
Chapter 4. List objects in Python
4.1 PyListObject object
4.2 PyListObject Creation and Maintenance
4.3 PyListObject Object buffer pool
4.4 Hack PyListObject
Chapter 5. Dict objects in Python
5.1 Overview of hash tables
5.2 PyDictObject
5.3 PyDictObject creation and maintenance
5.4 PyDictObject Object buffer pool
5.5 Hack PyDictObject
Chapter 6: The simplest Python simulation — Small Python
6.1 Small Python
6.2 Object Mechanism
6.3 Explanation Process
6.4 Interactive Environment
Part 2: The Python Virtual Machine
Chapter 7: Compilation results for Python — Code objects and PYC files
7.1 Execution process of Python Programs
7.2 Compilation result of the Python compiler – PyCodeObject object
7.3 Pyc File Generation
7.4 Python bytecode
7.5 Parsing pyC Files
Chapter 8 Python Virtual Machine Framework
8.1 Execution Environment on a Python VM
8.2 Names, scopes, and namespaces
8.3 Running Framework of the Python VM
8.4 A first look at the Python runtime environment
Chapter 9. General expressions in the Python Virtual machine
9.1 Creating simple built-in Objects
9.2 Creating complex built-in Objects
9.3 Other general expressions
Chapter 10. Control flow in the Python Virtual Machine
10.1 If Control flow in Python VIRTUAL Machines
10.2 For Control Flow in a Python VM
10.3 While loop control structures in Python VIRTUAL Machines
10.4 Exception Control Flow in Python VMS
Chapter 11. Functional mechanisms in the Python Virtual Machine
11.1 PyFunctionObject object
11.2 Function Call without parameters
11.3 Namespace for function execution
11.4 Implementation of function parameters
11.5 Access to local variables in functions
11.6 Nested Functions, closures, and decorators
Chapter 12. Class mechanisms in the Python Virtual Machine
12.1 Object Model in Python
12.2 Changing a Type Object to a Class Object
12.3 User-defined Classes
12.4 Changing a Class Object to an Instance Object
12.5 Accessing Properties in an Instance Object
12.6 Variable Descriptor
Chapter 13. Initialization of the Python runtime environment
13.1 Thread Environment Initialization
13.2 Initializing the System Module
13.3 Activating a Python VM
Chapter 14. Dynamic loading of Python modules
14.1 Import Prelude
14.2 Black box detection of import mechanisms in Python
14.3 Implementation of import mechanism
14.4 Import operations in Python
14.5 Namespace Issues related to Modules
Chapter 15. Python Multithreading
15.1 GIL and Thread scheduling
15.2 This Section describes the Python Thread
15.3 Creating Python Threads
15.4 Scheduling Python Threads
15.5 Destruction of Python child threads
15.6 User-level Mutual exclusion and synchronization of Python Threads
15.7 Advanced Thread library – Threading
Chapter 16: Python’s memory management mechanism
16.1 Memory Management Architecture
16.2 Memory Pool of Small Space
16.3 Garbage collection for circular references
16.4 Garbage collection in Python