Toggle table of contents sidebar
CPython source code¶This section gives an overview of CPython’s code structure and provides a summary of file locations for modules and built-ins.
Source code layout¶For a Python module, the typical layout is:
Lib/<module>.py
Modules/_<module>.c
(if there’s also a C accelerator module)
Lib/test/test_<module>.py
Doc/library/<module>.rst
For an extension module, the typical layout is:
Modules/<module>module.c
Lib/test/test_<module>.py
Doc/library/<module>.rst
For Built-in Types, the typical layout is:
Objects/<builtin>object.c
Lib/test/test_<builtin>.py
For Built-in Functions, the typical layout is:
Some exceptions to these layouts are:
built-in type int
is at Objects/longobject.c
built-in type str
is at Objects/unicodeobject.c
built-in module sys
is at Python/sysmodule.c
built-in module marshal
is at Python/marshal.c
Windows-only module winreg
is at PC/winreg.c
The CPython code base is constantly changing and evolving. Here’s a sample of references about CPython’s architecture aimed at building your understanding of CPython internals and its evolution:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4