PEP 454: rename filter() to add_filter(); update the PEP to the last implementation

This commit is contained in:
Victor Stinner 2013-09-08 15:58:01 +02:00
parent b1d112a783
commit 514324987d
1 changed files with 27 additions and 13 deletions

View File

@ -84,6 +84,21 @@ allocation. Use ``tracemalloc.set_number_frame()`` to store more frames.
Functions
---------
``add_filter(include: bool, filename: str, lineno: int=None)`` function:
Add a filter. If *include* is ``True``, only trace memory blocks
allocated in a file with a name matching *filename*. If
*include* is ``False``, don't trace memory blocks allocated in a
file with a name matching *filename*.
The match is done using *filename* as a prefix. For example,
``'/usr/bin/'`` only matchs files the ``/usr/bin`` directories. The
``.pyc`` and ``.pyo`` suffixes are automatically replaced with
``.py`` when matching the filename.
*lineno* is a line number. If *lineno* is ``None`` or lesser than
``1``, it matches any line number.
``clear_filters()`` function:
Reset the filter list.
@ -101,19 +116,6 @@ Functions
Start tracing Python memory allocations.
``filter(include: bool, filename: str, lineno: int=None)`` function:
Add a filter. If *include* is ``True``, only trace memory blocks
allocated in a file with a name matching *filename*. If
*include* is ``False``, don't trace memory blocks allocated in a
file with a name matching *filename*.
The match is done using *filename* as a prefix. For example,
``'/usr/bin/'`` only matchs files the ``/usr/bin`` directories.
*lineno* is a line number. If *lineno* is ``None`` or lesser than
``1``, it matches any line number.
``get_filters()`` function:
Get the filters as list of
@ -121,6 +123,9 @@ Functions
If *lineno* is ``None``, a filter matchs any line number.
By default, the filename of the Python tracemalloc module
(``tracemalloc.py``) is excluded.
``get_number_frame()`` function:
Get the maximum number of frames stored in a trace of a memory
@ -162,6 +167,10 @@ Functions
Return an empty dictionary if the tracemalloc module is disabled.
``get_tracemalloc_size()`` function:
Get the memory usage in bytes of the ``tracemalloc`` module.
``get_traces(obj)`` function:
Get all traces of a Python memory allocations.
@ -365,6 +374,11 @@ Snapshot class
Result of the ``get_stats()`` function.
``tracemalloc_size`` attribute (``int``):
The memory usage in bytes of the ``tracemalloc`` module,
result of the ``get_tracemalloc_size()`` function.
``timestamp`` attribute (``datetime.datetime``):
Creation date and time of the snapshot.