-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Move doc on structure from devguide to InternalDocs
#142237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
StanFromIreland
wants to merge
2
commits into
python:main
Choose a base branch
from
StanFromIreland:structure-from-devguide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # 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) | ||
|
|
||
|
|
||
| ## Additional references | ||
|
|
||
| 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: | ||
|
|
||
|
|
||
| ### Current references | ||
|
|
||
| | Title | Brief | Author | Version | | ||
| |------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|------------------|---------| | ||
| | [A guide from parser to objects, observed using GDB](https://hackmd.io/s/ByMHBMjFe) | Code walk from Parser, AST, Sym Table and Objects | Louie Lu | 3.7.a0 | | ||
| | [Green Tree Snakes](https://greentreesnakes.readthedocs.io/en/latest/) | The missing Python AST docs | Thomas Kluyver | 3.6 | | ||
| | [Yet another guided tour of CPython](https://paper.dropbox.com/doc/Yet-another-guided-tour-of-CPython-XY7KgFGn88zMNivGJ4Jzv) | A guide for how CPython REPL works | Guido van Rossum | 3.5 | | ||
| | [Python Asynchronous I/O Walkthrough](https://www.youtube.com/playlist?list=PLpEcQSRWP2IjVRlTUptdD05kG-UkJynQT) | How CPython async I/O, generator and coroutine works | Philip Guo | 3.5 | | ||
| | [Coding Patterns for Python Extensions](https://pythonextensionpatterns.readthedocs.io/en/latest/) | Reliable patterns of coding Python Extensions in C | Paul Ross | 3.9+ | | ||
| | [Your Guide to the CPython Source Code](https://realpython.com/cpython-source-code-guide/) | Your Guide to the CPython Source Code | Anthony Shaw | 3.8 | | ||
|
|
||
|
|
||
| ### Historical references | ||
|
|
||
| | Title | Brief | Author | Version | | ||
| |---------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|-----------------|---------| | ||
| | [Python's Innards Series](https://tech.blog.aknin.name/category/my-projects/pythons-innards/) | ceval, objects, pystate and miscellaneous topics | Yaniv Aknin | 3.1 | | ||
| | [Eli Bendersky's Python Internals](https://eli.thegreenplace.net/tag/python-internals) | Objects, Symbol tables and miscellaneous topics | Eli Bendersky | 3.x | | ||
| | [A guide from parser to objects, observed using Eclipse](https://docs.google.com/document/d/1nzNN1jeNCC_bg1LADCvtTuGKvcyMskV1w8Ad2iLlwoI/) | Code walk from Parser, AST, Sym Table and Objects | Prashanth Raghu | 2.7.12 | | ||
| | [CPython internals: A ten-hour codewalk through the Python interpreter source code](https://www.youtube.com/playlist?list=PLzV58Zm8FuBL6OAv1Yu6AwXZrnsFbbR0S) | Code walk from source code to generators | Philip Guo | 2.7.8 | | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.