Files
Ned Batchelder 59c4bddb17 Docs: split builtins to their own page from library (#156682)
* Docs: split builtins to their own page from library

* review feedback

* addressed Hugo's feedback

* update the What's Next page

* one more wording tweak

* move builtins to their own directory. fix the reference name

* moved pages need to be noted in tools/removed-ids.txt

* add Python to the builtins reference title

* add sphinxext-rediraffe for the library->builtins split

* update check-html-ids to handle rediraffe redirects

* now we don't need (page missing) for the redirected pages

* update other references to moved pages

* A seealso from builtins to library

* make a nice section for rediraffe settings

* move the builtins note to the end, as a seealso

* address merwok's comments

* cache looking for ids in files

* simplify the intro paragraphs
2026-09-13 11:55:44 -04:00

41 lines
1.3 KiB
Markdown

# 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 builtin types, the typical layout is:
* `Objects/<builtin>object.c`
* `Lib/test/test_<builtin>.py`
* [`Doc/builtins/stdtypes.rst`](../Doc/builtins/stdtypes.rst)
For builtin functions, the typical layout is:
* [`Python/bltinmodule.c`](../Python/bltinmodule.c)
* [`Lib/test/test_builtin.py`](../Lib/test/test_builtin.py)
* [`Doc/builtins/functions.rst`](../Doc/builtins/functions.rst)
Some exceptions to these layouts are:
* built-in type `int` is at [`Objects/longobject.c`](../Objects/longobject.c)
* built-in type `str` is at [`Objects/unicodeobject.c`](../Objects/unicodeobject.c)
* built-in module `sys` is at [`Python/sysmodule.c`](../Python/sysmodule.c)
* built-in module `marshal` is at [`Python/marshal.c`](../Python/marshal.c)
* Windows-only module `winreg` is at [`PC/winreg.c`](../PC/winreg.c)