python幕後解釋器:一系列的學習資源

做者:豌豆花下貓html

來源:Python貓python

花下貓語:最近我發現了一個《Python behind the scenes》系列文章,它計劃深度地剖析python 幕後的 CPython 解釋器的工做原理。做者專門建了一個網站來發布該系列文章,目前已發佈 4 篇。這些文章都挺長的,想要翻譯好,並不容易。而本文接下來的內容,是該做者分享的一篇簡短的參考材料,我先翻譯出來熱熱身~~架構


原文:https://tenthousandmeters.com...ide

做者:Victor Skvortsov學習

譯者:豌豆花下貓(「Python貓」公衆號做者)網站

聲明:本翻譯是出於交流學習的目的,基於 CC BY-NC-SA 4.0 受權協議。爲便於閱讀,內容略有改動。ui

在研究 CPython 以及寫做《CPython behind the scenes》系列時,我發現了一些頗有用的文檔、帖子和演講。它們確實是一些很是好的資源,可是並不能回答個人太多問題。這就是爲何我最終決定要分享本身在學習 CPython 源代碼時的經驗。idea

Python 文檔。在全部與 Python 相關的主題上,Python 文檔幾乎都是第一的查閱選擇。雖然它缺乏涵蓋解釋器原理的特殊內容,可是 Python/C API 文檔描述了 CPython 的公共接口和一些實現細節。它附錄了一份《the tutorial for C programmers》,該教程展現瞭如何使用 C 語言來擴展 Python 程序,或者將 Python 嵌入到 C 應用程序中。我敢打賭,只要認真地完成這些閱讀內容,你就會對 CPython 的工做原理至關地瞭解。

PEP。雖然沒有哪一個 PEP 描述瞭解釋器的整體設計,可是對 Python 的大多數主要更改,都有相應的提案。PEP 很贊。它們提供了技術和歷史的背景。文檔的做者們習慣於適當地引用相關的 PEP。例如,Python/C API 的參考內容中至少提到了一次 PEP-432,描述了 CPython 新的初始化序列的轉變,以及 PEP-587(這是其部分的實現)。spa

Obi Ike-Nwosu 寫的《 Inside The Python Virtual Machine》一書。在我看來,它是關於 CPython 內部原理的最全面、最準確的資料。.net

Anthony Shaw 寫的《Your Guide to the CPython Source Code》。這個標題不言而喻。若是想直接研究源代碼,你應該選擇它!

Philip Guo 寫的《CPython internals: A ten-hour codewalk through the Python interpreter source code》。若是你想要更爲簡單的介紹,那麼這些講座視頻多是最好的開始。它們基於 CPython 2.7,可是原理保持不變。

Yaniv Aknin 寫的《Python’s Innards series》,介紹的是 CPython 3 VM 的早期版本,但仍然很是有用。

Eli Bendersky 寫的《Python internals》文章。關於符號表(symbol table)的帖子特別好。

Stupid Python Ideas 博客。有各類 Python 相關主題的文章。有些涉及 CPython 內部原理。強烈推薦,但可能很差檢索。

Allison Kaptur 寫的《A Python Interpreter Written in Python》。它介紹了一個玩具版 Python VM,可以執行真正的 Python 字節碼。這做爲解釋器的入門介紹,可能會頗有用。可是,我以爲沒必要要花大量時間研究一個玩具示例,由於 CPython 自己並無那麼複雜。

Eric Snow 的演講《To GIL or not to GIL》。它的主題是子解釋過程。我喜歡它的地方是 Eric 在開頭描述 CPython 架構的方式。

參考材料:

一、Python behind the scenes (https://tenthousandmeters.com/)

二、the tutorial for C programmers (https://docs.python.org/3.9/e...

三、Inside The Python Virtual Machine (https://leanpub.com/insidethe...

四、Your Guide to the CPython Source Code (https://realpython.com/cpytho...

五、CPython internals: A ten-hour codewalk through the Python interpreter source code (https://www.youtube.com/playl...

六、Python’s Innards series (https://tech.blog.aknin.name/...

七、Python internals (https://eli.thegreenplace.net...

八、Stupid Python Ideas (http://stupidpythonideas.blog...

九、A Python Interpreter Written in Python (http://aosabook.org/en/500L/a...

十、To GIL or not to GIL (https://www.youtube.com/watch...

相關文章
相關標籤/搜索