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

相关推荐
赵谨言10 分钟前
基于python二手车价值评估系统的设计与实现
大数据·开发语言·经验分享·python
朝朝辞暮i10 分钟前
从0开始学python(day1)
python
love530love28 分钟前
【笔记】Podman Desktop 部署 开源数字人 HeyGem.ai
人工智能·windows·笔记·python·容器·开源·podman
gfdgd xi1 小时前
deepin 终端,但是版本是 deepin 15 的
linux·python·架构·ssh·bash·shell·deepin
王六岁1 小时前
🐍 前端开发 0 基础学 Python 入门指南:条件语句篇
前端·python
java1234_小锋1 小时前
PyTorch2 Python深度学习 - 初识PyTorch2,实现一个简单的线性神经网络
开发语言·python·深度学习·pytorch2
高洁011 小时前
大模型-模型压缩:量化、剪枝、蒸馏、二值化 (4)
人工智能·python·深度学习·aigc·transformer
王六岁1 小时前
# 🐍 前端开发 0 基础学Python小结 Python数据类型使用场景与用途指南
前端·python
luoganttcc1 小时前
用Python的trimesh库计算3DTiles体积的具体代码示例
开发语言·python·3d
我狸才不是赔钱货4 小时前
Python的“环境之殇”:从Venv到Conda的终极抉择
开发语言·python·conda