《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)

相关推荐
Linzerox1 小时前
Pycharm 取消拼写错误检查(Typo:in word xxx)
python·pycharm
千里码aicood1 小时前
[含文档+PPT+源码等]精品基于Python实现的校园小助手小程序的设计与实现
开发语言·前端·python
Icomi_2 小时前
【神经网络】0.深度学习基础:解锁深度学习,重塑未来的智能新引擎
c语言·c++·人工智能·python·深度学习·神经网络
蠟筆小新工程師2 小时前
Deepseek可以通过多种方式帮助CAD加速工作
开发语言·python·seepdeek
NoBarLing2 小时前
python将目录下的所欲md文件转化为html和pdf
python·pdf·html
岱宗夫up3 小时前
【Python】Django 中的算法应用与实现
数据库·python·opencv·django·sqlite
天道有情战天下3 小时前
python flask
开发语言·python·flask
秀儿还能再秀5 小时前
淘宝母婴购物数据可视化分析(基于脱敏公开数据集)
python·数据分析·学习笔记·数据可视化
计算机老学长5 小时前
基于Python的商品销量的数据分析及推荐系统
开发语言·python·数据分析
千益6 小时前
玩转python:系统设计模式在Python项目中的应用
python·设计模式