Skip to content

Commit d46f90a

Browse files
docs: describe CPython code generation tools
1 parent dce8cdf commit d46f90a

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.. _code-generation:
2+
3+
=====================
4+
Code generation tools
5+
=====================
6+
7+
CPython uses scripts to generate some source files from higher-level inputs.
8+
When changing an input that has generated files, use the corresponding
9+
``make`` target from the root of the checkout to update the generated output.
10+
11+
Frozen modules
12+
==============
13+
14+
The ``Tools/build/freeze_modules.py`` script generates C sources for frozen
15+
standard-library modules. Run the ``regen-frozen`` target after changing a
16+
module that is frozen::
17+
18+
make regen-frozen
19+
20+
The build invokes ``Tools/build/deepfreeze.py`` to turn frozen bytecode into C
21+
data. It is normally run as part of the build process rather than as a manual
22+
regeneration command.
23+
24+
Global objects
25+
==============
26+
27+
The ``Tools/build/generate_global_objects.py`` script generates definitions for
28+
global objects and strings. The ``regen-global-objects`` target also runs
29+
Argument Clinic first, then updates the generated global-object files::
30+
31+
make regen-global-objects
32+
33+
See :ref:`clinic` for details about editing Argument Clinic input and
34+
regenerating its output. For parser changes, see the :ref:`parser guide
35+
<grammar>`.
36+
37+
To run the set of regeneration targets listed by ``regen-all``::
38+
39+
make regen-all
40+
41+
This may update generated files for tools beyond the ones described here.
42+
Inspect the changes and include only generated files relevant to your change.
43+

‎development-tools/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Development tools
88
:maxdepth: 5
99

1010
clinic/index
11+
code-generation
1112
gdb
1213
sanitizers
1314
warnings

0 commit comments

Comments
 (0)