Skip to content
Closed
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
4 changes: 2 additions & 2 deletions developer-workflow/c-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ This helps us ensure *newly added* API is consistent and maintainable.

Also check with the C API WG before requiring a C feature not present in C99.
While the *public* docs only promise compatibility with C11, in practice
we only intruduce C11 features individually as needed.
we only introduce C11 features individually as needed.

.. _decisions repo: https://github.com/capi-workgroup/decisions/issues

Expand Down 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
2 changes: 1 addition & 1 deletion developer-workflow/extension-modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ Now that the configuration is in place, it remains to compile the project:
:mod:`!_foo` discoverable and importable via ``import _foo``.

* The final ``make`` step is generally not needed since the previous ``make``
invokations may completely rebuild the project, but it could be needed in
invocations may completely rebuild the project, but it could be needed in
some specific cases.

Troubleshooting
Expand Down
2 changes: 1 addition & 1 deletion documentation/devguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lives in a `separate repository`_ and bug reports should be submitted to the
Changes to the Developer's Guide are published when pull requests are merged.

Changes to the Python documentation are published regularly,
ususally within 48 hours of the change being committed.
usually within 48 hours of the change being committed.
The documentation is also `published for each release <https://docs.python.org/release/>`__,
which may also be used by redistributors.

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/blob/main/InternalDocs/README.md

.. _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.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ sphinx-notfound-page>=1.0.0
sphinx_copybutton>=0.3.3
sphinxext-opengraph>=0.13.0
sphinxext-rediraffe
Sphinx>=8.2.3
Sphinx~=8.2.3
Loading