《CPython Internals》读后感

一、 为什么选择这本书?

Python 是本人工作中最常用的开发语言,为了加深对 Python 的理解,更好的掌握 Python 这门语言,所以想对 Python 解释器有所了解,看看是怎么使用C语言来实现Python的,以期达到对 Python语言的掌握达到精通的程度,。

关于 Python 解释器的书不多------Anthony Shaw写的《CPython Internals》,陈儒写的《Python源码剖析》。

因为《CPython Internals》在2021年出版,使用的是Python3,比较新。而《Python源码剖析》在 2008 年出版,使用的是Python 2.5,比较古早。所以先阅读《CPython Internals》。

二、这本书写了什么?

这本书以 CPython 3.9 为例,讲解了编译基本操作(configure, make),内存管理(引用技术、垃圾回收), 并行和并发,基本数据类型(builtin types, dict),测试(unitest),调试(debug), 基准测试(timeit,pyperformance),性能分析(cProfile)。

从2025年1月6日至2025年1月26日,期间花了20天阅读完《CPython Internals》。

三、这本书特点

这是一本写得很混乱,阅读起来让人感到很痛苦的书。

当我在"About the Author"章节看到"Anthony has been programming since the age of 12 and found a love for Python while trapped inside a hotel in Seattle, Washington, 15 years later"------当看到这里,我是很兴奋的:作者 12 岁开始学习编程,27 岁接触 Python,具有这么丰富的编程经验的人那妥妥的是个大佬。但是,阅读完这本书后,我只能说和我想的不一样。

整本书充满很多无意义的口水话。例如:p13,CPython gives the developer writing Python code the platform to write scalable and performant applications。这句话包含形容词 scalabe 和 performant,这种形容词用在哪里都可以,说了等于没说。

整本书很多内容没有说到本质。例如:The first is profile, a pure-Python profiler, and the second, cProfile, a faster profiler written in C. In most cases, cProfile is the best module to use------在大多数情况下,cProfile是最好的模块,既然如此,那么为什么还要使用 profiler 呢?仅仅因为 cProfiler 是 C 语言写,更快?

很多概念没有明确定义。示例:The benchmark suite is the tool to use when comparing the complete performance of Python. The Python Benchmark suite is a collection of Python applications designed to test multiple aspects of the Python runtime under load.如果按照作者所给的定义"The benchmark suite is the tool to use when comparing the complete performance of Python.",那么 timeit 也算一个 benchmark suite, 但是,timeit 不能算作 benchmark suie,可以算一个 benchmark tool。

总而言之,没必要把时间浪费在这本书上面。

四、这本书适合什么样的人?

不建议阅读。

五、推荐指数

按照5 星的标准,本书推荐指数 1 颗星。

六、参考资料

1. 编程

(1) Anthony Shaw,《CPython Internals》:https://book.douban.com/subject/35405785/

2. 英语

(1) Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)

相关推荐
Samuel-Gyx32 分钟前
2025第十六届蓝桥杯python B组满分题解(详细)
python·职场和发展·蓝桥杯
行者无疆xcc1 小时前
【Django】设置让局域网内的人访问
后端·python·django
患得患失9491 小时前
【后端】【python】Python 爬虫常用的框架解析
开发语言·爬虫·python
愚公搬代码3 小时前
【愚公系列】《Python网络爬虫从入门到精通》058-自定义分布式爬取诗词排行榜数据
分布式·爬虫·python
不会飞的鲨鱼3 小时前
【某比特币网址请求头部sign签名】RSA加密逆向分析
javascript·爬虫·python
令狐少侠20113 小时前
AI之pdf解析:Tesseract、PaddleOCR、RapidPaddle(可能为 RapidOCR)和 plumberpdf 的对比分析及使用建议
人工智能·python·pdf
世界的尽头在哪里3 小时前
python测试框架之pytest
开发语言·python·测试工具·单元测试·pytest
_一条咸鱼_3 小时前
Python 语法之注释详解(二)
人工智能·python·面试
小洛~·~4 小时前
《深度学习入门:基于Python的理论与实现》第四章神经网络的学习—上篇(损失函数登场)
python·深度学习·神经网络
bjxiaxueliang4 小时前
一文详解opencv-python环境搭建:Mac配置python的cv2开发环境
python·opencv·macos