Skip to content

Commit cebe80b

Browse files
Scott Sandersonmethane
authored andcommitted
bpo-29235: Update document for Profiler's context manager (GH-7331)
1 parent fffeb6f commit cebe80b

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

Doc/library/profile.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ functions:
272272

273273
pr.print_stats()
274274

275+
.. versionchanged:: 3.8
276+
Added context manager support.
277+
275278
.. method:: enable()
276279

277280
Start collecting profiling data.

Doc/whatsnew/3.8.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ Changes in the Python API
151151
``type.__new__``. A :exc:`DeprecationWarning` was emitted in Python
152152
3.6--3.7. (Contributed by Serhiy Storchaka in :issue:`23722`.)
153153

154+
* The :class:`cProfile.Profile` class can now be used as a context
155+
manager. (Contributed by Scott Sanderson in :issue:`29235`.)
154156

155157
CPython bytecode changes
156158
------------------------
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
The :class:`cProfile.Profile` class can now be used as a context manager.
2-
You can profile a block of code by running::
3-
4-
import cProfile
5-
with cProfile.Profile() as profiler:
6-
# ... code to be profiled ...
7-
8-
Patch by Scott Sanderson.
1+
The :class:`cProfile.Profile` class can now be used as a context manager. Patch
2+
by Scott Sanderson.

0 commit comments

Comments
 (0)