Move doc on structure from devguide to InternalDocs (GH-142237)

Co-Authored-By: Paul Ross <apaulross@gmail.com>
Co-Authored-By: Carol Willing <carolcode@willingconsulting.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-Authored-By: Ezio Melotti <ezio.melotti@gmail.com>
Co-Authored-By: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
Stan Ulbrych 2025-12-15 14:19:02 +00:00 committed by GitHub
parent e4d32a3ef9
commit a7501f07da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

View file

@ -11,6 +11,11 @@ # CPython Internals Documentation
[issue tracker](https://github.com/python/cpython/issues).
General Resources
---
- [Source Code Structure](structure.md)
Compiling Python Source Code
---

40
InternalDocs/structure.md Normal file
View file

@ -0,0 +1,40 @@
# 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/library/stdtypes.rst`](../Doc/library/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/library/functions.rst`](../Doc/library/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)