File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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
155157CPython bytecode changes
156158------------------------
Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments