《CPython Internals》阅读笔记:p285-p328
《CPython Internals》学习第 15 天,p285-p328 总结,总计 44 页。
一、技术总结
1.shallow comparison
p285, In Objects object.c, the base implementation of the object type is written in pure C code. There are some concrete implementations of basic logic, like shallow comparisons(《CPython Internals》第 285 页)。
shallow 和 deep 这两个词常见于 copy(shallow copy, deep copy) 和 comparison(shallow comparison, deep comparison) 操作中。
但是个人觉得从字面意思不好理解。示例:TBD。
2.dunder method
All these functions can be overridden in a custom object by implementing dunder methods on a Python object(《CPython Internals》第 286 页)。
看到 dunder methods, 一下子没反应过来什么样的方法叫 dunder methods, dunder 是什么意思?查了下,dunder 是 double under 的缩写,其实是为了发音(pronunce)方便, 由 Mark Jackson 提出:
An awkward thing about programming in Python: there are lots of double underscores. [snip] My problem with the double underscore is that it's hard to say. How do you pronounce init? "underscore underscore init underscore underscore"? "under under init under under"? Just plain "init" seems to leave out something important. I have a solution: double underscore should be pronounced "dunder". So init is "dunder init dunder", or just "dunder init".
dunder method 也称为 magic method 或者 special method。
二、英语总结(生词:2)
无。
关于英语的注解同步更新汇总到 https://github.com/codists/English-In-CS-Books 仓库。
三、其它
无。
四、参考资料
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)
版权声明: 本文为 InfoQ 作者【codists】的原创文章。
原文链接:【http://xie.infoq.cn/article/2689cc9ac828738848b7555a1】。文章转载请联系作者。
评论