Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@
"pullrequest.rst": "getting-started/pull-request-lifecycle.rst",
"setup.rst": "getting-started/setup-building.rst",
# CPython Internals
"compiler.rst": "internals/compiler.rst",
"exploring.rst": "internals/exploring.rst",
"garbage_collector.rst": "internals/garbage-collector.rst",
"parser.rst": "internals/parser.rst",
"compiler.rst": "internals.rst",
"exploring.rst": "internals.rst",
"garbage_collector.rst": "internals.rst",
"parser.rst": "internals.rst",
"internals/compiler.rst": "internals.rst",
"internals/exploring.rst": "internals.rst",
"internals/garbage_collector.rst": "internals.rst",
"internals/parser.rst": "internals.rst",
# Testing and Buildbots
"buildbots.rst": "testing/buildbots.rst",
"coverage.rst": "testing/coverage.rst",
Expand Down
2 changes: 1 addition & 1 deletion developer-workflow/c-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Guidelines for adding to the Limited API
details involve:

- The GIL
- :ref:`Garbage collection <gc>`
- Garbage collection
- Memory layout of PyObject, lists/tuples and other structures

If following these guidelines would hurt performance, add a fast function
Expand Down
7 changes: 2 additions & 5 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,8 @@ Additional resources
* Anyone can clone the sources for this guide. See :ref:`devguide`.
* Help with ...

* :ref:`exploring`
* :ref:`internals`
* :ref:`grammar`
* :ref:`parser`
* :ref:`compiler`
* :ref:`garbage_collector`

* Tool support

Expand Down Expand Up @@ -317,7 +314,7 @@ Full table of contents
testing/index
development-tools/index
core-team/index
internals/index
internals
versions
contrib/index

Expand Down
50 changes: 4 additions & 46 deletions internals/exploring.rst → internals.rst
Original file line number Diff line number Diff line change
@@ -1,53 +1,9 @@
.. _exploring:
.. _internals:

===================
CPython source code
CPython's internals
===================

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 :term:`module`, the typical layout is:

* :file:`Lib/{<module>}.py`
* :file:`Modules/_{<module>}.c` (if there's also a C accelerator module)
* :file:`Lib/test/test_{<module>}.py`
* :file:`Doc/library/{<module>}.rst`

For an :term:`extension module`, the typical layout is:

* :file:`Modules/{<module>}module.c`
* :file:`Lib/test/test_{<module>}.py`
* :file:`Doc/library/{<module>}.rst`

For :ref:`bltin-types`, the typical layout is:

* :file:`Objects/{<builtin>}object.c`
* :file:`Lib/test/test_{<builtin>}.py`
* :cpy-file:`Doc/library/stdtypes.rst`

For :ref:`built-in-funcs`, the typical layout is:

* :cpy-file:`Python/bltinmodule.c`
* :cpy-file:`Lib/test/test_builtin.py`
* :cpy-file:`Doc/library/functions.rst`

Some exceptions to these layouts are:

* built-in type ``int`` is at :cpy-file:`Objects/longobject.c`
* built-in type ``str`` is at :cpy-file:`Objects/unicodeobject.c`
* built-in module ``sys`` is at :cpy-file:`Python/sysmodule.c`
* built-in module ``marshal`` is at :cpy-file:`Python/marshal.c`
* Windows-only module ``winreg`` is at :cpy-file:`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:
Expand All @@ -56,6 +12,7 @@ building your understanding of CPython internals and its evolution:
:header: "Title", "Brief", "Author", "Version"
:widths: 50, 50, 20, 5

"`CPython's InternalDocs`_", "Docs on CPython internals maintained in the source tree", "", ""
"`A guide from parser to objects, observed using GDB`_", "Code walk from Parser, AST, Sym Table and Objects", Louie Lu, 3.7.a0
"`Green Tree Snakes`_", "The missing Python AST docs", Thomas Kluyver, 3.6
"`Yet another guided tour of CPython`_", "A guide for how CPython REPL works", Guido van Rossum, 3.5
Expand All @@ -72,6 +29,7 @@ building your understanding of CPython internals and its evolution:
"`A guide from parser to objects, observed using Eclipse`_", "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`_", "Code walk from source code to generators", Philip Guo, 2.7.8

.. _CPython's InternalDocs: https://github.com/python/cpython/tree/main/InternalDocs

.. _A guide from parser to objects, observed using GDB: https://hackmd.io/s/ByMHBMjFe

Expand Down
10 changes: 0 additions & 10 deletions internals/compiler.rst

This file was deleted.

12 changes: 0 additions & 12 deletions internals/garbage-collector.rst

This file was deleted.

20 changes: 0 additions & 20 deletions internals/index.rst

This file was deleted.

8 changes: 0 additions & 8 deletions internals/interpreter.rst

This file was deleted.

10 changes: 0 additions & 10 deletions internals/parser.rst

This file was deleted.

Loading