Skip to content

Commit a7501f0

Browse files
StanFromIrelandpaulrosswillingchugovkezio-melotti
authored
Move doc on structure from devguide to InternalDocs (GH-142237)
Co-Authored-By: Paul Ross <[email protected]> Co-Authored-By: Carol Willing <[email protected]> Co-Authored-By: Hugo van Kemenade <[email protected]> Co-Authored-By: Ezio Melotti <[email protected]> Co-Authored-By: Adam Turner <[email protected]>
1 parent e4d32a3 commit a7501f0

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

InternalDocs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ it is not, please report that through the
1111
[issue tracker](https://github.com/python/cpython/issues).
1212

1313

14+
General Resources
15+
---
16+
17+
- [Source Code Structure](structure.md)
18+
1419
Compiling Python Source Code
1520
---
1621

InternalDocs/structure.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# CPython source code
2+
3+
This section gives an overview of CPython's code structure and provides
4+
a summary of file locations for modules and built-ins.
5+
6+
7+
## Source code layout
8+
9+
For a Python module, the typical layout is:
10+
11+
* `Lib/<module>.py`
12+
* `Modules/_<module>.c` (if there's also a C accelerator module)
13+
* `Lib/test/test_<module>.py`
14+
* `Doc/library/<module>.rst`
15+
16+
For an extension module, the typical layout is:
17+
18+
* `Modules/<module>module.c`
19+
* `Lib/test/test_<module>.py`
20+
* `Doc/library/<module>.rst`
21+
22+
For builtin types, the typical layout is:
23+
24+
* `Objects/<builtin>object.c`
25+
* `Lib/test/test_<builtin>.py`
26+
* [`Doc/library/stdtypes.rst`](../Doc/library/stdtypes.rst)
27+
28+
For builtin functions, the typical layout is:
29+
30+
* [`Python/bltinmodule.c`](../Python/bltinmodule.c)
31+
* [`Lib/test/test_builtin.py`](../Lib/test/test_builtin.py)
32+
* [`Doc/library/functions.rst`](../Doc/library/functions.rst)
33+
34+
Some exceptions to these layouts are:
35+
36+
* built-in type `int` is at [`Objects/longobject.c`](../Objects/longobject.c)
37+
* built-in type `str` is at [`Objects/unicodeobject.c`](../Objects/unicodeobject.c)
38+
* built-in module `sys` is at [`Python/sysmodule.c`](../Python/sysmodule.c)
39+
* built-in module `marshal` is at [`Python/marshal.c`](../Python/marshal.c)
40+
* Windows-only module `winreg` is at [`PC/winreg.c`](../PC/winreg.c)

0 commit comments

Comments
 (0)