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

相关推荐
Sylvan Ding42 分钟前
PyTorch Lightning实战 - 训练 MNIST 数据集
人工智能·pytorch·python·lightning
水银嘻嘻1 小时前
web 自动化之 Unittest 应用:报告&装饰器&断言
前端·python·自动化
攻城狮7号1 小时前
Python爬虫第20节-使用 Selenium 爬取小米商城空调商品
开发语言·数据库·爬虫·python·selenium
虚空之月&&轮舞者3 小时前
Python与矢量网络分析仪3671E:自动化测试(Vscode)
网络·vscode·python·射频工程
李昊哲小课3 小时前
tensorflow-cpu
大数据·人工智能·python·深度学习·数据分析·tensorflow
小彭律师9 小时前
数字化工厂中央控制室驾驶舱系统架构文档
python
old_power10 小时前
【Python】PDF文件处理(PyPDF2、borb、fitz)
python·pdf
测试开发Kevin10 小时前
从投入产出、效率、上手难易度等角度综合对比 pytest 和 unittest 框架
python·pytest
强化学习与机器人控制仿真10 小时前
Newton GPU 机器人仿真器入门教程(零)— NVIDIA、DeepMind、Disney 联合推出
开发语言·人工智能·python·stm32·深度学习·机器人·自动驾驶
Tiny番茄11 小时前
No module named ‘xxx’报错原因及解决方式
开发语言·python