|  | 
|  | 1 | + | 
|  | 2 | +# The CPython Repository | 
|  | 3 | + | 
|  | 4 | +This section gives an overview of CPython's code structure and provides | 
|  | 5 | +a summary of file locations for modules and built-ins. | 
|  | 6 | + | 
|  | 7 | +Source code layout | 
|  | 8 | +================== | 
|  | 9 | + | 
|  | 10 | +The core interpreter implementation is in the [`Python/`](../Python) directory. | 
|  | 11 | +Some of the files there are generated during the build process, that will be | 
|  | 12 | +indicated by a comment at the top of the file. | 
|  | 13 | + | 
|  | 14 | +For a Python [`module`](https://docs.python.org/3/glossary.html#term-module), | 
|  | 15 | +the typical layout is: | 
|  | 16 | + | 
|  | 17 | +* `Lib/{<module>}.py` | 
|  | 18 | +* `Modules/_{<module>}.c` (if there's also a C accelerator module) | 
|  | 19 | +* `Lib/test/test_{<module>}.py` | 
|  | 20 | +* `Doc/library/{<module>}.rst` | 
|  | 21 | + | 
|  | 22 | +For an [`extension module`](https://docs.python.org/3/glossary.html#term-extension-module), | 
|  | 23 | +the typical layout is: | 
|  | 24 | + | 
|  | 25 | +* `Modules/{<module>}module.c` | 
|  | 26 | +* `Lib/test/test_{<module>}.py` | 
|  | 27 | +* `Doc/library/{<module>}.rst` | 
|  | 28 | + | 
|  | 29 | +For [`bltin-types`](https://docs.python.org/3/library/stdtypes.html#bltin-types), | 
|  | 30 | +the typical layout is: | 
|  | 31 | + | 
|  | 32 | +* `Objects/{<builtin>}object.c` | 
|  | 33 | +* `Lib/test/test_{<builtin>}.py` | 
|  | 34 | +* [`Doc/library/stdtypes.rst`](../Doc/library/stdtypes.rst) | 
|  | 35 | + | 
|  | 36 | +For [`built-in-funcs`](https://docs.python.org/3/library/functions.html#built-in-funcs), | 
|  | 37 | +the typical layout is: | 
|  | 38 | + | 
|  | 39 | +* [`Python/bltinmodule.c`](../Python/bltinmodule.c) | 
|  | 40 | +* [`Lib/test/test_builtin.py`](../Lib/test/test_builtin.py) | 
|  | 41 | +* [`Doc/library/functions.rst`](../Doc/library/functions.rst) | 
|  | 42 | + | 
|  | 43 | +Some exceptions to these layouts are: | 
|  | 44 | + | 
|  | 45 | +* built-in type ``int`` is at [`Objects/longobject.c`](../Objects/longobject.c) | 
|  | 46 | +* built-in type ``str`` is at [`Objects/unicodeobject.c`](../Objects/unicodeobject.c) | 
|  | 47 | +* built-in module ``sys`` is at [`Python/sysmodule.c`](../Python/sysmodule.c) | 
|  | 48 | +* built-in module ``marshal`` is at [`Python/marshal.c`](../Python/marshal.c) | 
|  | 49 | +* Windows-only module ``winreg`` is at [`PC/winreg.c`](../PC/winreg.c) | 
0 commit comments