Skip to content

Commit 4279785

Browse files
authored
gh-140727: Restructure profiling documentation for PEP 799 (#142373)
* Add profiling module documentation structure PEP 799 introduces a new `profiling` package that reorganizes Python's profiling tools under a unified namespace. This commit adds the documentation structure to match: a main entry point (profiling.rst) that helps users choose between profilers, detailed docs for the tracing profiler (profiling-tracing.rst), and separated pstats documentation. The tracing profiler docs note that cProfile remains as a backward-compatible alias, so existing code continues to work. The pstats module gets its own page since it's used by both profiler types and deserves focused documentation. * Add profiling.sampling documentation The sampling profiler is new in Python 3.15 and works fundamentally differently from the tracing profiler. It observes programs from outside by periodically capturing stack snapshots, which means zero overhead on the profiled code. This makes it practical for production use where you can attach to live servers. The docs explain the key concepts (statistical vs deterministic profiling), provide quick examples upfront, document all output formats (pstats, flamegraph, gecko, heatmap), and cover the live TUI mode. The defaults table helps users understand what happens without any flags. * Wire profiling docs into the documentation tree Add the new profiling module pages to the Debugging and Profiling toctree. The order places the main profiling.rst entry point first, followed by the two profiler implementations, then pstats, and finally the deprecated profile module last. * Convert profile.rst to deprecation stub The pure Python profile module is deprecated in 3.15 and scheduled for removal in 3.17. Users should migrate to profiling.tracing (or use the cProfile alias which continues to work). The page now focuses on helping existing users migrate: it shows the old vs new import style, keeps the shared API reference since both modules have the same interface, and preserves the calibration docs for anyone still using the pure Python implementation during the transition period. * Update CLI module references for profiling restructure Point cProfile to profiling.tracing docs and add profiling.sampling to the list of modules with CLI interfaces. The old profile-cli label no longer exists after the documentation restructure. * Update whatsnew to link to profiling module docs Enable cross-references to the new profiling module documentation and update the CLI examples to use the current syntax with the attach subcommand. Also reference profiling.tracing instead of cProfile since that's the new canonical name.
1 parent 8914148 commit 4279785

28 files changed

+2156
-713
lines changed

Doc/library/cmdline.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The following modules have a command-line interface.
1212
* :ref:`calendar <calendar-cli>`
1313
* :mod:`code`
1414
* :ref:`compileall <compileall-cli>`
15-
* :mod:`cProfile`: see :ref:`profile <profile-cli>`
15+
* ``cProfile``: see :ref:`profiling.tracing <profiling-tracing-cli>`
1616
* :ref:`dis <dis-cli>`
1717
* :ref:`doctest <doctest-cli>`
1818
* :mod:`!encodings.rot_13`
@@ -31,8 +31,9 @@ The following modules have a command-line interface.
3131
* :ref:`pickletools <pickletools-cli>`
3232
* :ref:`platform <platform-cli>`
3333
* :mod:`poplib`
34-
* :ref:`profile <profile-cli>`
35-
* :mod:`pstats`
34+
* :ref:`profiling.sampling <profiling-sampling>`
35+
* :ref:`profiling.tracing <profiling-tracing-cli>`
36+
* :ref:`pstats <pstats-cli>`
3637
* :ref:`py_compile <py_compile-cli>`
3738
* :mod:`pyclbr`
3839
* :mod:`pydoc`

Doc/library/debug.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
***********************
2-
Debugging and Profiling
2+
Debugging and profiling
33
***********************
44

55
These libraries help you with Python development: the debugger enables you to
@@ -15,7 +15,8 @@ intrusive debugging or patching.
1515
bdb.rst
1616
faulthandler.rst
1717
pdb.rst
18-
profile.rst
18+
profiling.rst
19+
pstats.rst
1920
timeit.rst
2021
trace.rst
2122
tracemalloc.rst

0 commit comments

Comments
 (0)