Skip to content

Commit 366e735

Browse files
committed
📝 New features in Python 3.15
* profiling.tracing and profiling.sampling * Tachyon * Python JIT compiler
1 parent aa54d2c commit 366e735

File tree

4 files changed

+124
-4
lines changed

4 files changed

+124
-4
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
"https://jupyter-tutorial.readthedocs.io/en/latest",
156156
None,
157157
),
158-
"python": ("https://docs.python.org/3", None),
158+
"python": ("https://docs.python.org/3.15", None),
159159
"ipython": ("https://ipython.readthedocs.io/en/latest", None),
160160
"pytest": ("https://docs.pytest.org/en/latest", None),
161161
"jupyter-notebook": (

docs/performance/index.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,20 @@ Performance measurements
6262
------------------------
6363

6464
Once you have worked with your code, it can be useful to examine its efficiency
65-
more closely. :mod:`cProfile`, :doc:`ipython-profiler` or :doc:`scalene` can be
66-
used for this.
65+
more closely. `cProfile
66+
<https://docs.python.org/3.14/library/profile.html#module-cProfile>`_,
67+
:doc:`ipython-profiler` or :doc:`scalene` can be used for this.
68+
69+
.. versionadded:: Python3.15
70+
:pep:`799` will provide a special profiling module that organises the
71+
profiling tools integrated in Python under a uniform namespace. This module
72+
contains:
73+
74+
:mod:`profiling.tracing`
75+
deterministic function call tracing, which has been moved from `cProfile
76+
<https://docs.python.org/3.14/library/profile.html#module-cProfile>`_.
77+
:mod:`profiling.sampling`
78+
the new statistical sampling profiler :doc:`tachyon`.
6779

6880
.. seealso::
6981
* `airspeed velocity (asv) <https://asv.readthedocs.io/en/stable/>`_
@@ -81,6 +93,7 @@ used for this.
8193

8294
ipython-profiler.ipynb
8395
scalene.ipynb
96+
tachyon
8497

8598
Search for existing implementations
8699
-----------------------------------
@@ -220,6 +233,20 @@ If you don’t want to wait with your project until the release of Python 3.11 i
220233
the final version probably on 24 October 2022, you can also have a look at the
221234
following Python interpreters:
222235

236+
Python JIT compiler
237+
~~~~~~~~~~~~~~~~~~~
238+
239+
.. versionadded:: Python3.15
240+
The `JIT <https://en.wikipedia.org/wiki/Just-in-time_compilation>`_ compiler
241+
in Python 3.15 shows an average performance increase of 3–4% compared to the
242+
standard CPython interpreter, with performance measurements varying between
243+
-20 and over 100% on x86-64 Linux and AArch64 macOS systems.
244+
245+
.. seealso::
246+
* `The JIT Compiler
247+
<https://github.com/python/cpython/blob/main/Tools/jit/README.md>`_
248+
* :ref:`whatsnew315-jit`
249+
223250
Cython
224251
~~~~~~
225252

docs/performance/tachyon.rst

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Tachyon
2+
=======
3+
4+
Tachyon is a new statistical sampling profiler that was added to Python 3.15 as
5+
:mod:`profiling.sampling`. This profiler enables powerful analysis of running
6+
Python processes with low overhead, without requiring code changes or a process
7+
restart.
8+
9+
Unlike deterministic profilers such as :mod:`profiling.tracing`, which
10+
instrument every function call, :mod:`profiling.sampling` regularly collects
11+
stack traces from running processes.
12+
13+
Key features include:
14+
15+
Profiling without overhead
16+
:mod:`profiling.sampling` integrates into any running Python process without
17+
affecting its performance. This is ideal for debugging in production
18+
environments where your application cannot be restarted or slowed down.
19+
No code changes required
20+
Existing applications can be profiled without restarting. Simply point the
21+
profiler at a running process using its PID and start collecting data.
22+
Profiles running processes or modules
23+
:samp:`attach`
24+
profiles running processes using their PID.
25+
:samp:`run -m {MODULE}`
26+
runs modules and profiles them.
27+
Multiple profiling modes
28+
You can choose what to measure:
29+
30+
``--mode wall``
31+
Default value that measures the actual elapsed time, including I/O,
32+
network latency, and blocking operations. This is ideal for
33+
understanding where your programme is spending time, including waiting
34+
for external resources.
35+
``--mode cpu``
36+
measures only active CPU execution time, excluding I/O wait times and
37+
blocking. Use this option to identify CPU-bound bottlenecks and optimise
38+
computing power.
39+
``--mode gil``
40+
measures the time spent on Python’s :abbr:`GIL (Global Interpreter
41+
Lock)`. Use this option to determine which threads are being slowed down
42+
by the GIL.
43+
``--mode exception``
44+
only collects samples from threads with an active exception. Use this
45+
option to analyse the overhead of exception handling.
46+
``-a``
47+
profiles all threads or only the main thread, increasing understanding
48+
of the behaviour of multithreaded applications.
49+
50+
Multiple output formats
51+
Choose the visualisation that best suits your workflow:
52+
53+
``--pstats``
54+
provides detailed tabular statistics, compatible with :mod:`pstats`. It
55+
displays timing at the function level with direct and cumulative samples
56+
and is best suited for detailed analysis and integration with existing
57+
Python profiling tools.
58+
``--collapsed``
59+
generates summarised stack traces. This format is specifically designed
60+
for creating `flame graphs
61+
<https://www.brendangregg.com/flamegraphs.html>`_ with external tools
62+
such as `Brendan Gregg’s FlameGraph scripts
63+
<https://github.com/brendangregg/FlameGraph>`_ or `Speedscope
64+
<https://jamie-wong.com/post/speedscope/>`_.
65+
``--flamegraph``
66+
generates a standalone interactive HTML flame graph using `D3.js
67+
<https://d3js.org/>`_, which opens directly in your browser for
68+
immediate visual analysis.
69+
``--gecko``
70+
generates a Gecko profiler format that is compatible with `Firefox
71+
Profiler <https://profiler.firefox.com>`_. The output can be uploaded to
72+
Firefox Profiler to perform advanced timeline-based analysis with
73+
features such as bar charts, markers, and network activity.
74+
``--heatmap``
75+
rgGenerates an interactive HTML heatmap visualisation and creates one
76+
heatmap per file, showing exactly where time is spent at the source code
77+
level.
78+
79+
``--live``
80+
`top <https://man7.org/linux/man-pages/man1/top.1.html>`_-like interface,
81+
allowing you to monitor your application’s performance during execution with
82+
interactive sorting and filtering.
83+
``--async-aware``
84+
Profiles :doc:`async/await code <asyncio-example>`, showing you which
85+
coroutines are consuming time. Additional options show you only running
86+
tasks or all tasks, including those that are waiting.
87+
``--opcodes``
88+
collects bytecode opcode information for instruction-level profiling and
89+
shows which bytecode instructions are being executed, including
90+
specialisations from the adaptive interpreter.
91+
92+
.. seealso::
93+
:mod:`profiling.sampling`

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ docs = [
3838
"matplotlib",
3939
"nbsphinx",
4040
"notebook",
41-
"sphinx<8.2",
41+
"sphinx<8.2", # furo requires sphinx < 8.2
4242
"sphinx-copybutton",
4343
"sphinx-inline-tabs",
4444
"sphinx-lint",

0 commit comments

Comments
 (0)