PEP 454: merge two "functions" sections
This commit is contained in:
parent
20e6c78e68
commit
2a339ac8f5
105
pep-0454.txt
105
pep-0454.txt
|
@ -100,8 +100,8 @@ tracemalloc=25`` command line option. The ``set_traceback_limit()``
|
|||
function can be used at runtime to set the limit.
|
||||
|
||||
|
||||
Main functions
|
||||
--------------
|
||||
Functions
|
||||
---------
|
||||
|
||||
``clear_traces()`` function:
|
||||
|
||||
|
@ -110,6 +110,26 @@ Main functions
|
|||
See also ``stop()``.
|
||||
|
||||
|
||||
``get_object_traceback(obj)`` function:
|
||||
|
||||
Get the traceback where the Python object *obj* was allocated.
|
||||
Return a ``Traceback`` instance, or ``None`` if the ``tracemalloc``
|
||||
module is not tracing memory allocations or did not trace the
|
||||
allocation of the object.
|
||||
|
||||
See also ``gc.get_referrers()`` and ``sys.getsizeof()`` functions.
|
||||
|
||||
|
||||
``get_traceback_limit()`` function:
|
||||
|
||||
Get the maximum number of frames stored in the traceback of a trace.
|
||||
|
||||
By default, a trace of a memory block only stores the most recent
|
||||
frame: the limit is ``1``.
|
||||
|
||||
Use the ``set_traceback_limit()`` function to change the limit.
|
||||
|
||||
|
||||
``get_traced_memory()`` function:
|
||||
|
||||
Get the current size and maximum size of memory blocks traced by the
|
||||
|
@ -130,6 +150,29 @@ Main functions
|
|||
See also ``start()`` and ``stop()`` functions.
|
||||
|
||||
|
||||
``set_traceback_limit(nframe: int)`` function:
|
||||
|
||||
Set the maximum number of frames stored in the traceback of a trace.
|
||||
|
||||
Storing more frames allocates more memory of the ``tracemalloc``
|
||||
module and makes Python slower. Use the ``get_tracemalloc_memory()``
|
||||
function to measure how much memory is used by the ``tracemalloc``
|
||||
module.
|
||||
|
||||
Storing more than ``1`` frame is only useful to compute statistics
|
||||
grouped by ``'traceback'`` or to compute cumulative statistics: see
|
||||
the ``Snapshot.statistics()`` method.
|
||||
|
||||
If the limit is set to ``0`` frame, a traceback with a frame will be
|
||||
used for all traces: filename ``'<unknown>'`` at line number ``0``.
|
||||
|
||||
Use the ``get_traceback_limit()`` function to get the current limit.
|
||||
|
||||
The ``PYTHONTRACEMALLOC`` environment variable
|
||||
(``PYTHONTRACEMALLOC=NFRAME``) and the ``-X`` ``tracemalloc=NFRAME``
|
||||
command line option can be used to set the limit at startup.
|
||||
|
||||
|
||||
``start()`` function:
|
||||
|
||||
Start tracing Python memory allocations: install hooks on Python
|
||||
|
@ -167,57 +210,6 @@ Main functions
|
|||
See also the ``get_object_traceback()`` function.
|
||||
|
||||
|
||||
Trace functions
|
||||
---------------
|
||||
|
||||
When Python allocates a memory block, ``tracemalloc`` attachs a "trace" to
|
||||
the memory block to store its size in bytes and the traceback where the
|
||||
allocation occurred. See the ``Trace`` class.
|
||||
|
||||
|
||||
``get_object_traceback(obj)`` function:
|
||||
|
||||
Get the traceback where the Python object *obj* was allocated.
|
||||
Return a ``Traceback`` instance, or ``None`` if the ``tracemalloc``
|
||||
module is not tracing memory allocations or did not trace the
|
||||
allocation of the object.
|
||||
|
||||
See also ``gc.get_referrers()`` and ``sys.getsizeof()`` functions.
|
||||
|
||||
|
||||
``get_traceback_limit()`` function:
|
||||
|
||||
Get the maximum number of frames stored in the traceback of a trace.
|
||||
|
||||
By default, a trace of a memory block only stores the most recent
|
||||
frame: the limit is ``1``.
|
||||
|
||||
Use the ``set_traceback_limit()`` function to change the limit.
|
||||
|
||||
|
||||
``set_traceback_limit(nframe: int)`` function:
|
||||
|
||||
Set the maximum number of frames stored in the traceback of a trace.
|
||||
|
||||
Storing more frames allocates more memory of the ``tracemalloc``
|
||||
module and makes Python slower. Use the ``get_tracemalloc_memory()``
|
||||
function to measure how much memory is used by the ``tracemalloc``
|
||||
module.
|
||||
|
||||
Storing more than ``1`` frame is only useful to compute statistics
|
||||
grouped by ``'traceback'`` or to compute cumulative statistics: see
|
||||
the ``Snapshot.statistics()`` method.
|
||||
|
||||
If the limit is set to ``0`` frame, a traceback with a frame will be
|
||||
used for all traces: filename ``'<unknown>'`` at line number ``0``.
|
||||
|
||||
Use the ``get_traceback_limit()`` function to get the current limit.
|
||||
|
||||
The ``PYTHONTRACEMALLOC`` environment variable
|
||||
(``PYTHONTRACEMALLOC=NFRAME``) and the ``-X`` ``tracemalloc=NFRAME``
|
||||
command line option can be used to set the limit at startup.
|
||||
|
||||
|
||||
Filter
|
||||
------
|
||||
|
||||
|
@ -233,10 +225,9 @@ Filter
|
|||
|
||||
* ``Filter(True, subprocess.__file__)`` only includes traces of the
|
||||
``subprocess`` module
|
||||
* ``Filter(False, tracemalloc.__file__)``
|
||||
excludes traces of the ``tracemalloc`` module.
|
||||
* ``Filter(False,
|
||||
"<unknown>")`` excludes empty tracebacks
|
||||
* ``Filter(False, tracemalloc.__file__)`` excludes traces of the
|
||||
``tracemalloc`` module
|
||||
* ``Filter(False, "<unknown>")`` excludes empty tracebacks
|
||||
|
||||
``inclusive`` attribute:
|
||||
|
||||
|
|
Loading…
Reference in New Issue