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

相关推荐
运器1231 小时前
【一起来学AI大模型】PyTorch DataLoader 实战指南
大数据·人工智能·pytorch·python·深度学习·ai·ai编程
音元系统1 小时前
Copilot 在 VS Code 中的免费替代方案
python·github·copilot
超龄超能程序猿1 小时前
(5)机器学习小白入门 YOLOv:数据需求与图像不足应对策略
人工智能·python·机器学习·numpy·pandas·scipy
cooldream20093 小时前
Python 包管理新时代:深入了解 `uv` 的使用与实践
python·uv·包管理器
之歆3 小时前
Python-魔术方法-创建、初始化与销毁-hash-bool-可视化-运算符重载-容器和大小-可调用对象-上下文管理-反射-描述器-二分-学习笔记
笔记·python·学习
胖达不服输3 小时前
「日拱一码」025 机器学习——评价指标
人工智能·python·机器学习·评价指标
brave_zhao5 小时前
JavaBeanUtils javaBean转map, 实体类转map,实体集合转List<Map>
linux·windows·python
apihz6 小时前
通用图片搜索-搜狗源免费API接口使用指南
android·java·python·php·音视频
爱吃面条的猿6 小时前
pycharm中自动补全方法返回变量
ide·python·pycharm
倔强青铜三6 小时前
苦练Python第15天:Lambda函数——Python的匿名一行杀器
人工智能·python·面试