Dive into CPython internals, trying to illustrate every detail of CPython implementation
Cpython Internals
- ็ฎไฝไธญๆ
- ํ๊ตญ์ด
- Watch this repo if you need to be notified when there's an update
It attempts to illustrate every detail of CPython implementation
script
based on version 3.8.0a0
cd cpython
git reset --hard ab54b9a130c88f708077c2ef6c4963b632c132b3
The following content is suitable for those who have Python programming experience and are interested in the internals of the Python interpreter. For those who need beginner or advanced material, please refer to awesome-python-books
Table of Contents
Objects
- [x] dict - [x] long/int - [x] unicode/str - [x] set - [x] list(timsort) - [x] tuple - [x] bytes - [x] bytearray(buffer protocol) - [x] float - [x] func(user-defined method) - [x] method(builtin method) - [x] iter - [x] gen(generator/coroutine/async generator) - [x] class(bound method/classmethod/staticmethod) - [x] complex - [x] enum - [x] type(mro/metaclass/creation of class/instance)Modules
- [ ] io - [x] fileio - [x] pickle
Lib
- [x] re(regex) - [ ] asyncio
Interpreter
- [x] gil(Global Interpreter Lock) - [x] gc(Garbage Collection) - [x] memory management - [x] descr(how does attribute access work/get/getattribute/getattr) - [x] exception(exception handling) - [x] module(how does import work) - [x] frame - [x] code - [x] slots/slots(how does attribute initialized in the creation of class/instance) - [x] thread - [x] PyObject(overview)
Extension
- [x] C API(profile python code and write pure C extension) - [ ] Cython(C extension) - [x] Boost C++ libaries (C\+\+ extension) - [ ] C++ extension - [x] integrate with NumPy - [x] bypass the GIL
Grammar
- [x] Compile Phase - [x] Grammar/MetaGrammar to DFA - [x] CST to AST - [x] AST to python byte code
Learning material
I only recommend materials I've read
- CPython internals - Interpreter and source code overview(youtube video)
- < < Inside The Python Virtual Machine > >
- < < Pythonๆบ็ ๅๆ > >
- rushter(blog/eng)
- YET ANOTHER PYTHON INTERNALS BLOG(blog/eng)
- Junnplus(blog/cn)
- manjusaka(blog/cn)
- aoik-Python's compiler series(blog/eng)
Contribution
All kinds of contributions are welcome
- submit a pull request
- open an issue