Skip to content

Commit 3d3a4be

Browse files
gh-128563: Document the tail-calling interpreter (GH-129728)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent a3d5aab commit 3d3a4be

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Doc/using/configure.rst

+10
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,16 @@ also be used to improve performance.
618618
Enable computed gotos in evaluation loop (enabled by default on supported
619619
compilers).
620620

621+
.. option:: --with-tail-call-interp
622+
623+
Enable interpreters using tail calls in CPython. If enabled, enabling PGO
624+
(:option:`--enable-optimizations`) is highly recommended. This option specifically
625+
requires a C compiler with proper tail call support, and the
626+
`preserve_none <https://clang.llvm.org/docs/AttributeReference.html#preserve-none>`_
627+
calling convention. For example, Clang 19 and newer supports this feature.
628+
629+
.. versionadded:: next
630+
621631
.. option:: --without-mimalloc
622632

623633
Disable the fast :ref:`mimalloc <mimalloc>` allocator

Doc/whatsnew/3.14.rst

+25
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Summary -- release highlights
6868
* :ref:`PEP 649: deferred evaluation of annotations <whatsnew314-pep649>`
6969
* :ref:`PEP 741: Python Configuration C API <whatsnew314-pep741>`
7070
* :ref:`PEP 761: Discontinuation of PGP signatures <whatsnew314-pep761>`
71+
* :ref:`A new tail-calling interpreter <whatsnew314-tail-call>`
7172

7273

7374
New features
@@ -208,6 +209,30 @@ configuration mechanisms).
208209
.. seealso::
209210
:pep:`741`.
210211

212+
.. _whatsnew314-tail-call:
213+
214+
A new tail-calling interpreter
215+
------------------------------
216+
217+
A new type of interpreter based on tail calls has been added to CPython.
218+
For certain newer compilers, this interpreter provides
219+
significantly better performance. Preliminary numbers on our machines suggest
220+
anywhere from -3% to 30% faster Python code, and a geometric mean of 9-15%
221+
faster on ``pyperformance`` depending on platform and architecture.
222+
223+
This interpreter currently only works with Clang 19 and newer
224+
on x86-64 and AArch64 architectures. However, we expect
225+
that a future release of GCC will support this as well.
226+
227+
This feature is opt-in for now. We highly recommend enabling profile-guided
228+
optimization with the new interpreter as it is the only configuration we have
229+
tested and can validate its improved performance.
230+
For further information on how to build Python, see
231+
:option:`--with-tail-call-interp`.
232+
233+
(Contributed by Ken Jin in :gh:`128718`, with ideas on how to implement this
234+
in CPython by Mark Shannon, Garret Gu, Haoran Xu, and Josh Haberman.)
235+
211236

212237
Other language changes
213238
======================

0 commit comments

Comments
 (0)