From d46f90a9699aa1d613a3d3604ee3831aebdf8db3 Mon Sep 17 00:00:00 2001 From: Badri Vishal Pandey Date: Tue, 27 Oct 2026 21:02:32 +0530 Subject: [PATCH 1/2] docs: describe CPython code generation tools --- development-tools/code-generation.rst | 43 +++++++++++++++++++++++++++ development-tools/index.rst | 1 + 2 files changed, 44 insertions(+) create mode 100644 development-tools/code-generation.rst diff --git a/development-tools/code-generation.rst b/development-tools/code-generation.rst new file mode 100644 index 000000000..14dd2e050 --- /dev/null +++ b/development-tools/code-generation.rst @@ -0,0 +1,43 @@ +.. _code-generation: + +===================== +Code generation tools +===================== + +CPython uses scripts to generate some source files from higher-level inputs. +When changing an input that has generated files, use the corresponding +``make`` target from the root of the checkout to update the generated output. + +Frozen modules +============== + +The ``Tools/build/freeze_modules.py`` script generates C sources for frozen +standard-library modules. Run the ``regen-frozen`` target after changing a +module that is frozen:: + + make regen-frozen + +The build invokes ``Tools/build/deepfreeze.py`` to turn frozen bytecode into C +data. It is normally run as part of the build process rather than as a manual +regeneration command. + +Global objects +============== + +The ``Tools/build/generate_global_objects.py`` script generates definitions for +global objects and strings. The ``regen-global-objects`` target also runs +Argument Clinic first, then updates the generated global-object files:: + + make regen-global-objects + +See :ref:`clinic` for details about editing Argument Clinic input and +regenerating its output. For parser changes, see the :ref:`parser guide +`. + +To run the set of regeneration targets listed by ``regen-all``:: + + make regen-all + +This may update generated files for tools beyond the ones described here. +Inspect the changes and include only generated files relevant to your change. + diff --git a/development-tools/index.rst b/development-tools/index.rst index cdd415fd5..db3e40195 100644 --- a/development-tools/index.rst +++ b/development-tools/index.rst @@ -8,6 +8,7 @@ Development tools :maxdepth: 5 clinic/index + code-generation gdb sanitizers warnings From b3666ec0601cc7c4a72aad5b48cb4dfb5b34b293 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 15:32:47 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- development-tools/code-generation.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/development-tools/code-generation.rst b/development-tools/code-generation.rst index 14dd2e050..4f4eab572 100644 --- a/development-tools/code-generation.rst +++ b/development-tools/code-generation.rst @@ -40,4 +40,3 @@ To run the set of regeneration targets listed by ``regen-all``:: This may update generated files for tools beyond the ones described here. Inspect the changes and include only generated files relevant to your change. -