1
1
PEP: 799
2
- Title: A dedicated ``profilers `` package for organizing Python profiling tools
2
+ Title: A dedicated ``profiling `` package for organizing Python profiling tools
3
3
Author: Pablo Galindo <pablogsal@python.org>,
4
- László Kiss Kollár <kiss.kollar.laszlo@gmail.com>,
5
- Discussions-To: Pending
4
+ László Kiss Kollár <kiss.kollar.laszlo@gmail.com>
5
+ Discussions-To: https://discuss.python.org/t/pep-799-a-dedicated-profilers-package-for-organizing-python-profiling-tool/100898
6
6
Status: Draft
7
7
Type: Standards Track
8
8
Created: 21-Jul-2025
@@ -13,7 +13,7 @@ Abstract
13
13
========
14
14
15
15
This PEP proposes the creation of a new standard library module named
16
- :mod: `!profilers ` to organize Python's built-in profiling tools under a single,
16
+ :mod: `!profiling ` to organize Python's built-in profiling tools under a single,
17
17
coherent namespace.
18
18
19
19
This PEP also proposes the deprecation of the :mod: `profile ` module, a legacy
@@ -54,42 +54,43 @@ This reorganization addresses several long-standing issues with Python’s profi
54
54
First, it improves **discoverability ** by collecting all built-in profilers
55
55
under a single, clearly named namespace. Currently, profiling tools are
56
56
scattered across modules with inconsistent naming and unclear relationships. By
57
- introducing the ``profilers `` module, users will have a well-defined and
57
+ introducing the ``profiling `` module, users will have a well-defined and
58
58
intuitive location to explore and access profiling functionality.
59
59
60
60
Second, the proposal enhances **clarity ** by naming the submodules according to
61
- their underlying methodology -- ``profilers .tracing `` for deterministic tracing
62
- profilers and ``profilers .sampling `` for statistical sampling profilers. This
61
+ their underlying methodology -- ``profiling .tracing `` for deterministic tracing
62
+ profilers and ``profiling .sampling `` for statistical sampling profilers. This
63
63
explicit categorization makes it easier to understand the behavior and
64
64
limitations of each tool and aligns the API with the mental model users are
65
65
encouraged to adopt.
66
66
67
67
Third, it provides **guidance ** to developers by making the recommended tools
68
68
easier to find and use. The current structure can mislead users into relying on
69
69
outdated or less performant modules like ``profile ``, simply because of naming
70
- precedence. With the ``profilers `` namespace and its clearer semantics, users
70
+ precedence. With the ``profiling `` namespace and its clearer semantics, users
71
71
are more likely to choose the appropriate profiler for their specific use case,
72
72
whether it involves low-overhead sampling or detailed tracing.
73
73
74
74
Finally, this structure promotes **extensibility **. By consolidating profiling
75
75
tools under a unified namespace, it becomes straightforward to introduce future
76
76
profiling capabilities -- such as memory profilers, I/O profilers, or hybrid
77
77
tools -- without overloading unrelated modules or adding redundant top-level names.
78
- The ``profilers `` module provides a natural home for this.
78
+ The ``profiling `` module provides a natural home for this.
79
79
80
80
Specification
81
81
=============
82
82
83
83
New Module Structure
84
84
--------------------
85
85
86
- This PEP introduces a new ``profilers `` module containing:
86
+ This PEP introduces a new ``profiling `` module containing:
87
87
88
- - ``profilers .tracing ``: an alias for ``cProfile ``, providing deterministic function-call tracing .
89
- - ``profilers .sampling ``: an alias for `` profilers.tachyon ``, improving visibility and semantic clarity .
88
+ - ``profiling .tracing ``: deterministic function-call tracing (relocated from ``cProfile ``) .
89
+ - ``profiling .sampling ``: the statistical sampling profiler (tachyon) .
90
90
91
- Additionally the **code ** for the ``tachyon `` profiler will be also relocated to
92
- the module as ``profilers.tachyon ``.
91
+ The ``cProfile `` implementation will be relocated to ``profiling.tracing ``, with ``cProfile ``
92
+ remaining as an alias for backwards compatibility. The tachyon sampling profiler will be
93
+ available at ``profiling.sampling ``.
93
94
94
95
Deprecation of ``profile ``
95
96
--------------------------
@@ -100,20 +101,20 @@ The ``profile`` module will be deprecated starting in Python 3.15.
100
101
- In Python 3.16: all uses of ``profile `` emit a ``DeprecationWarning ``.
101
102
- In Python 3.17: the module will be removed from the standard library.
102
103
103
- From Python 3.15, :mod: `!profilers .tracing ` will be preferred to :mod: `!cProfile ` & :mod: `!profile `.
104
+ From Python 3.15, :mod: `!profiling .tracing ` will be preferred to :mod: `!cProfile ` & :mod: `!profile `.
104
105
105
106
The code that, at the time of writing, is in the :mod: `!profile.sampling `
106
- module will be moved to the :mod: `!profilers ` package.
107
+ module will be moved to the :mod: `!profiling ` package.
107
108
108
109
Documentation
109
110
=============
110
111
111
- The Python documentation will use the new :mod: `!profilers ` module as the canonical
112
+ The Python documentation will use the new :mod: `!profiling ` module as the canonical
112
113
entry point for profiling functionality. It will also describe the distinction between
113
114
tracing and sampling profilers, and include guidance on when each type is most appropriate.
114
115
115
- Documentation for ``cProfile `` and `` profile.sample `` will remain available but will link to
116
- the new ``profilers `` equivalents.
116
+ Documentation for ``cProfile `` will remain available but will link to
117
+ the new ``profiling `` equivalents.
117
118
118
119
Backwards Compatibility
119
120
=======================
@@ -134,13 +135,30 @@ Renaming ``cProfile``
134
135
135
136
Renaming ``cProfile `` to ``profile.tracing `` was considered, but this change would impact a
136
137
large amount of existing code. Maintaining the original name while aliasing it under
137
- ``profilers.tracing `` strikes a balance between compatibility and clarity.
138
+ ``profiling.tracing `` strikes a balance between compatibility and clarity.
139
+
140
+ Using ``profilers `` as the Module Name
141
+ ---------------------------------------
142
+
143
+ The module was initially proposed as ``profilers `` (plural) but was changed to ``profiling ``
144
+ (gerund form) based on community feedback. The gerund form is more consistent with other
145
+ Python standard library modules that represent categories of functionality.
146
+
147
+ Multiple Names for the Sampling Profiler
148
+ -----------------------------------------
149
+
150
+ An earlier version of this PEP proposed having the sampling profiler available under two names:
151
+ ``profiling.sampling `` and ``profiling.tachyon ``. This was rejected to avoid confusion - when
152
+ introducing new functionality, it's better to have a single, clear path to access it rather than
153
+ multiple aliases. The name ``profiling.sampling `` was chosen as it clearly describes the
154
+ profiling methodology, while "tachyon" remains as an internal codename that may be mentioned
155
+ in documentation.
138
156
139
157
Top-Level ``tachyon `` Module
140
158
----------------------------
141
159
142
160
Introducing ``import tachyon `` as a new top-level module was rejected. Grouping tachyon under
143
- ``profilers `` helps establish a logical structure and prevents proliferation of top-level modules
161
+ ``profiling `` helps establish a logical structure and prevents proliferation of top-level modules
144
162
and also minimizes the usage of global namespace as requested by the Python Steering Council.
145
163
146
164
Copyright
0 commit comments