1. Python 幕后解釋器:一系列的學(xué)習(xí)資源

        共 2814字,需瀏覽 6分鐘

         ·

        2021-04-28 11:04

        ????關(guān)注后回復(fù) “進(jìn)群” ,拉你進(jìn)程序員交流群????
        作者丨豌豆花下貓
        來源丨Python貓

        原文:https://tenthousandmeters.com/materials/python-behind-the-scenes-a-list-of-resources

        作者:Victor Skvortsov

        譯者:豌豆花下貓(“Python貓”公眾號(hào)作者)

        聲明:本翻譯是出于交流學(xué)習(xí)的目的,基于 CC BY-NC-SA 4.0 授權(quán)協(xié)議。為便于閱讀,內(nèi)容略有改動(dòng)。

        在研究 CPython 以及寫作《CPython behind the scenes》系列時(shí),我發(fā)現(xiàn)了一些很有用的文檔、帖子和演講。它們確實(shí)是一些非常好的資源,但是并不能回答我的太多問題。這就是為什么我最終決定要分享自己在學(xué)習(xí) CPython 源代碼時(shí)的經(jīng)驗(yàn)。

        >> Python 文檔。在所有與 Python 相關(guān)的主題上,Python 文檔幾乎都是第一的查閱選擇。雖然它缺少涵蓋解釋器原理的特殊內(nèi)容,但是 Python/C API 文檔描述了 CPython 的公共接口和一些實(shí)現(xiàn)細(xì)節(jié)。它附錄了一份《the tutorial for C programmers》,該教程展示了如何使用 C 語言來擴(kuò)展 Python 程序,或者將 Python 嵌入到 C 應(yīng)用程序中。我敢打賭,只要認(rèn)真地完成這些閱讀內(nèi)容,你就會(huì)對(duì) CPython 的工作原理相當(dāng)?shù)亓私狻?/p>

        >> PEP。雖然沒有哪個(gè) PEP 描述了解釋器的總體設(shè)計(jì),但是對(duì) Python 的大多數(shù)主要更改,都有相應(yīng)的提案。PEP 很贊。它們提供了技術(shù)和歷史的背景。文檔的作者們習(xí)慣于適當(dāng)?shù)匾孟嚓P(guān)的 PEP。例如,Python/C API 的參考內(nèi)容中至少提到了一次 PEP-432,描述了 CPython 新的初始化序列的轉(zhuǎn)變,以及 PEP-587(這是其部分的實(shí)現(xiàn))。

        >> Obi Ike-Nwosu 寫的《 Inside The Python Virtual Machine》一書。在我看來,它是關(guān)于 CPython 內(nèi)部原理的最全面、最準(zhǔn)確的資料。

        >> Anthony Shaw 寫的《Your Guide to the CPython Source Code》。這個(gè)標(biāo)題不言而喻。如果想直接研究源代碼,你應(yīng)該選擇它!

        >> Philip Guo 寫的《CPython internals: A ten-hour codewalk through the Python interpreter source code》。如果你想要更為簡(jiǎn)單的介紹,那么這些講座視頻可能是最好的開始。它們基于 CPython 2.7,但是原理保持不變。

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

        >> Eli Bendersky 寫的《Python internals》文章。關(guān)于符號(hào)表(symbol table)的帖子特別好。

        >> Stupid Python Ideas 博客。有各種 Python 相關(guān)主題的文章。有些涉及 CPython 內(nèi)部原理。強(qiáng)烈推薦,但可能不好檢索。

        >> Allison Kaptur 寫的《A Python Interpreter Written in Python》。它介紹了一個(gè)玩具版 Python VM,能夠執(zhí)行真正的 Python 字節(jié)碼。這作為解釋器的入門介紹,可能會(huì)很有用。但是,我覺得不必要花大量時(shí)間研究一個(gè)玩具示例,因?yàn)?CPython 本身并沒有那么復(fù)雜。

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

        參考材料:

        1、Python behind the scenes (https://tenthousandmeters.com/)
        2、the tutorial for C programmers (https://docs.python.org/3.9/extending/index.html#extending-index)
        3、Inside The Python Virtual Machine (https://leanpub.com/insidethepythonvirtualmachine)
        4、Your Guide to the CPython Source Code (https://realpython.com/cpython-source-code-guide/)
        5、CPython internals: A ten-hour codewalk through the Python interpreter source code (https://www.youtube.com/playlist?list=PLzV58Zm8FuBL6OAv1Yu6AwXZrnsFbbR0S)
        6、Python’s Innards series (https://tech.blog.aknin.name/category/my-projects/pythons-innards/)
        7、Python internals (https://eli.thegreenplace.net/tag/python-internals)
        8、Stupid Python Ideas (http://stupidpythonideas.blogspot.com/)
        9、A Python Interpreter Written in Python (http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html)
        10、To GIL or not to GIL (https://www.youtube.com/watch?v=7RlqbHCCVyc)

        -End-

        最近有一些小伙伴,讓我?guī)兔φ乙恍?nbsp;面試題 資料,于是我翻遍了收藏的 5T 資料后,匯總整理出來,可以說是程序員面試必備!所有資料都整理到網(wǎng)盤了,歡迎下載!

        點(diǎn)擊??卡片,關(guān)注后回復(fù)【面試題】即可獲取

        在看點(diǎn)這里好文分享給更多人↓↓

        瀏覽 21
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
        評(píng)論
        圖片
        表情
        推薦
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
          
          

            1. 嗯啊操| 午夜精品一区二区三区久久久播放 | 精品黑人XXXXXX在线观看 | 欧美熟女爱爱 | 日本少妇的性生活 |