zpoint /CPython-Internals

Dive into CPython internals, trying to illustrate every detail of CPython implementation

★ 5,091⑂ 477👁 336⑃ 23● 45▤ 0
CCreated 2019-04-15
+0
Daily
+0
Weekly
+9
Monthly
5,091
stars
477
forks
336
watchers
23
prs
45
issues
0
releases

README

Cpython Internals

!cpython logo

 简体中文
 한국어
  Watch this repo if you need to be notified when there's an update

This repository contains my notes/blog for cpython source code

It attempts to illustrate every detail of CPython implementation

shell 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
 Modules
 Lib
 Interpreter
 Extension
 Learning material
 Contribution
 License


 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)
  
  
 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
    if you want to share any knowledge you know
   post a new article
   correct any technical mistakes
   correct English grammar
   translation
   anything else
 open an issue
   any suggestions
   any questions
   correct mistakes
   anything else

 License

Snapshot: 2026-11-04T14:00:00Z · Data license Apache-2.0 · JSON