{"id":21177030,"url":"https://github.com/bat67/python-source-code-analysis","last_synced_at":"2025-07-09T21:32:34.534Z","repository":{"id":53577388,"uuid":"315627143","full_name":"bat67/python-source-code-analysis","owner":"bat67","description":"《Python源码剖析 深度探索动态语言核心技术》电子书, 配套资源, 配套代码","archived":false,"fork":false,"pushed_at":"2020-11-25T03:42:24.000Z","size":33504,"stargazers_count":94,"open_issues_count":1,"forks_count":32,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T07:51:14.488Z","etag":null,"topics":["analysis","code","python","source","source-code"],"latest_commit_sha":null,"homepage":"https://github.com/bat67/python-source-code-analysis","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bat67.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-24T12:35:42.000Z","updated_at":"2025-04-05T06:13:36.000Z","dependencies_parsed_at":"2022-09-12T12:33:49.319Z","dependency_job_id":null,"html_url":"https://github.com/bat67/python-source-code-analysis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bat67/python-source-code-analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bat67%2Fpython-source-code-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bat67%2Fpython-source-code-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bat67%2Fpython-source-code-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bat67%2Fpython-source-code-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bat67","download_url":"https://codeload.github.com/bat67/python-source-code-analysis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bat67%2Fpython-source-code-analysis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264503951,"owners_count":23618762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analysis","code","python","source","source-code"],"created_at":"2024-11-20T17:14:20.782Z","updated_at":"2025-07-09T21:32:32.781Z","avatar_url":"https://github.com/bat67.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python源码剖析：深度探索动态语言核心技术\n\n\u003e 前一阵终于把电子书（本仓库的pdf）、配套资源（本仓库的word）、配套代码（本仓库文件夹）找齐了！\n\u003e \n\u003e 虽然其Python版本已经很旧了，但不影响它为一本好书！与大家分享！\n\n\n## Introduction\n\n作为主流的动态语言，Python不仅简单易学、移植性好，而且拥有强大丰富的库的支持。此外，Python强大的可扩展性，让开发人员既可以非常容易地利用C/C++编写Python的扩展模块，还能将Python嵌入到C/C++程序中，为自己的系统添加动态扩展和动态编程的能力。\n\n为了更好地利用Python语言，无论是使用Python语言本身，还是将Python与C/C++交互使用，深刻理解Python的运行原理都是非常重要的。本书以CPython为研究对象，在C代码一级，深入细致地剖析了Python的实现。书中不仅包括了对大量Python内置对象的剖析，更将大量的篇幅用于对Python虚拟机及Python高级特性的剖析。通过此书，读者能够透彻地理解Python中的一般表达式、控制结构、异常机制、类机制、多线程机制、模块的动态加载机制、内存管理机制等核心技术的运行原理，同时，本书所揭示的动态语言的核心技术对于理解其他动态语言，如 Javascript、Ruby等也有较大的参考价值。\n\n本书适合于Python程序员、动态语言爱好者、C程序员阅读。\n\n\n\n\n\n## Resources\n\n- [作者的 CSDN 博客](https://blog.csdn.net/balabalamerobert)\n  - 可惜不再更新了\n\n- [Extending and Embedding the Python Interpreter](https://docs.python.org/3/extending/index.html)\n  - 扩展和嵌入 Python 解析器，介绍了如何用 C/C++ 编写 Python 的扩展模块，如何在其它语言中嵌入 Python 解释器\n\n- [Python/C API Reference Manual](https://docs.python.org/3/c-api/index.html)\n  - 详细介绍了 Python 内部的 C API\n\n- [Python Developer’s Guide](https://devguide.python.org/)\n  - Python 开发者指南\n\n- [有没有内容类似于《Python源码剖析》，但内容更新过，针对新版本的Python书籍 - 知乎](https://www.zhihu.com/question/40787248)\n  - 该书出版年份2008年，基于Python2.5，最新的相关内容见这个链接\n\n- [CPython-Internals - GitHub](https://github.com/zpoint/CPython-Internals)\n  - This repository is some notes/blog for cpython source code. Trying to illustrate every detail of cpython implementation\n\n\n## Chinese Version\n\n![cover](assets/cover.jpg)\n\n\n## Table of Contents\n\n* 第0章 Python源码剖析——编译Python\n    * 0.1 Python总体架构\n    * 0.2 Python源代码的组织\n    * 0.3 Windows环境下编译Python\n    * 0.4 Unix/Linux环境下编译Python\n    * 0.5 修改Python源代码\n    * 0.6 通往Python之路\n    * 0.7 一些注意事项\n\u003e 第1部分 Python内建对象\n* 第1章 Python对象初探\n    * 1.1 Python内的对象\n    * 1.2 类型对象\n    * 1.3 Python对象的多态性\n    * 1.4 引用计数\n    * 1.5 Python对象的分类\n* 第2章 Python中的整数对象\n    * 2.1 初识PyIntObject对象\n    * 2.2 PyIntObject对象的创建和维护\n    * 2.3 Hack PyIntObject\n* 第3章 Python中的字符串对象\n    * 3.1 PyStringObject与PyString_Type\n    * 3.2 创建PyStringObject对象\n    * 3.3 字符串对象的intern机制\n    * 3.4 字符缓冲池\n    * 3.5 PyStringObject效率相关问题\n    * 3.6 Hack PyStringObject\n* 第4章 Python中的List对象\n    * 4.1 PyListObject对象\n    * 4.2 PyListObject对象的创建与维护\n    * 4.3 PyListObject对象缓冲池\n    * 4.4 Hack PyListObject\n* 第5章 Python中的Dict对象\n    * 5.1 散列表概述\n    * 5.2 PyDictObject\n    * 5.3 PyDictObject的创建和维护\n    * 5.4 PyDictObject对象缓冲池\n    * 5.5 Hack PyDictObject\n* 第6章 最简单的Python模拟——Small Python\n* 6.1 Small Python\n* 6.2 对象机制\n* 6.3 解释过程\n* 6.4 交互式环境\n\u003e 第2部分 Python虚拟机\n* 第7章 Python的编译结果——Code对象与pyc文件\n    * 7.1 Python程序的执行过程\n    * 7.2 Python编译器的编译结果——PyCodeObject对象\n    * 7.3 Pyc文件的生成\n    * 7.4 Python的字节码\n    * 7.5 解析pyc文件\n* 第8章 Python虚拟机框架\n    * 8.1 Python虚拟机中的执行环境\n    * 8.2 名字、作用域和名字空间\n    * 8.3 Python虚拟机的运行框架\n    * 8.4 Python运行时环境初探\n* 第9章 Python虚拟机中的一般表达式\n    * 9.1 简单内建对象的创建\n    * 9.2 复杂内建对象的创建\n    * 9.3 其他一般表达式\n* 第10章 Python虚拟机中的控制流\n    * 10.1 Python虚拟机中的if控制流\n    * 10.2 Python虚拟机中的for循环控制流\n    * 10.3 Python虚拟机中的while循环控制结构\n    * 10.4 Python虚拟机中的异常控制流\n* 第11章 Python虚拟机中的函数机制\n    * 11.1 PyFunctionObject对象\n    * 11.2 无参函数调用\n    * 11.3 函数执行时的名字空间\n    * 11.4 函数参数的实现\n    * 11.5 函数中局部变量的访问\n    * 11.6 嵌套函数、闭包与decorator\n* 第12章 Python虚拟机中的类机制\n    * 12.1 Python中的对象模型\n    * 12.2 从type对象到class对象\n    * 12.3 用户自定义class\n    * 12.4 从class对象到instance对象\n    * 12.5 访问instance对象中的属性\n    * 12.6 千变万化的descriptor\n\u003e 第3部分 Python 高级话题  \n* 第13章 Python运行环境初始化\n    * 13.1 线程环境初始化\n    * 13.2 系统module初始化\n    * 13.3 激活Python虚拟机\n* 第14章 Python模块的动态加载机制\n    * 14.1 import前奏曲\n    * 14.2 Python中import机制的黑盒探测\n    * 14.3 import机制的实现\n    * 14.4 Python中的import操作\n    * 14.5 与module有关的名字空间问题\n* 第15章 Python多线程机制\n    * 15.1 GIL与线程调度\n    * 15.2 初见Python Thread\n    * 15.3 Python线程的创建\n    * 15.4 Python线程的调度\n    * 15.5 Python子线程的销毁\n    * 15.6 Python线程的用户级互斥与同步\n    * 15.7 高级线程库——threading\n* 第16章 Python的内存管理机制\n    * 16.1 内存管理架构\n    * 16.2 小块空间的内存池\n    * 16.3 循环引用的垃圾收集\n    * 16.4 Python中的垃圾收集\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbat67%2Fpython-source-code-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbat67%2Fpython-source-code-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbat67%2Fpython-source-code-analysis/lists"}