summaryrefslogtreecommitdiffstats
path: root/Doc/library/tracemalloc.rst
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2019-10-15 12:00:16 (GMT)
committerVictor Stinner <vstinner@python.org>2019-10-15 12:00:16 (GMT)
commit8d59eb1b66c51b2b918da9881c57d07d08df43b7 (patch)
tree7833df22bb4e8cd3779dfa4a7d5ee2a206ec0b90 /Doc/library/tracemalloc.rst
parentf3ef06a7cb347ab7bd3cc2b0b3dcebe4f9ff36f9 (diff)
downloadcpython-8d59eb1b66c51b2b918da9881c57d07d08df43b7.zip
cpython-8d59eb1b66c51b2b918da9881c57d07d08df43b7.tar.gz
cpython-8d59eb1b66c51b2b918da9881c57d07d08df43b7.tar.bz2
bpo-37961, tracemalloc: add Traceback.total_nframe (GH-15545)
Add a total_nframe field to the traces collected by the tracemalloc module. This field indicates the original number of frames before it was truncated.
Diffstat (limited to 'Doc/library/tracemalloc.rst')
-rw-r--r--Doc/library/tracemalloc.rst15
1 files changed, 15 insertions, 0 deletions
diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst
index 2d327c0..e423470 100644
--- a/Doc/library/tracemalloc.rst
+++ b/Doc/library/tracemalloc.rst
@@ -313,6 +313,9 @@ Functions
frames. By default, a trace of a memory block only stores the most recent
frame: the limit is ``1``. *nframe* must be greater or equal to ``1``.
+ You can still read the original number of total frames that composed the
+ traceback by looking at the :attr:`Traceback.total_nframe` attribute.
+
Storing more than ``1`` frame is only useful to compute statistics grouped
by ``'traceback'`` or to compute cumulative statistics: see the
:meth:`Snapshot.compare_to` and :meth:`Snapshot.statistics` methods.
@@ -659,6 +662,9 @@ Traceback
When a snapshot is taken, tracebacks of traces are limited to
:func:`get_traceback_limit` frames. See the :func:`take_snapshot` function.
+ The original number of frames of the traceback is stored in the
+ :attr:`Traceback.total_nframe` attribute. That allows to know if a traceback
+ has been truncated by the traceback limit.
The :attr:`Trace.traceback` attribute is an instance of :class:`Traceback`
instance.
@@ -666,6 +672,15 @@ Traceback
.. versionchanged:: 3.7
Frames are now sorted from the oldest to the most recent, instead of most recent to oldest.
+ .. attribute:: total_nframe
+
+ Total number of frames that composed the traceback before truncation.
+ This attribute can be set to ``None`` if the information is not
+ available.
+
+ .. versionchanged:: 3.9
+ The :attr:`Traceback.total_nframe` attribute was added.
+
.. method:: format(limit=None, most_recent_first=False)
Format the traceback as a list of lines with newlines. Use the