diff options
author | Larry Hastings <larry@hastings.org> | 2014-03-17 05:54:05 (GMT) |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-03-17 05:54:05 (GMT) |
commit | 3c5c56f3c068bc13daea2275b951113b43a91e85 (patch) | |
tree | 1395bfb10902b7087a4ca1551f4bdb271b55ed43 /Lib/tracemalloc.py | |
parent | e41b73caca2b543422f423a2ac07c29de834f44d (diff) | |
parent | 2221f666eba4a6f46f2095a801bc3e4bdbdb97d2 (diff) | |
download | cpython-3c5c56f3c068bc13daea2275b951113b43a91e85.zip cpython-3c5c56f3c068bc13daea2275b951113b43a91e85.tar.gz cpython-3c5c56f3c068bc13daea2275b951113b43a91e85.tar.bz2 |
Merged default into 3.4 branch. 3.4 branch is now effectively 3.4.1rc1.
Diffstat (limited to 'Lib/tracemalloc.py')
-rw-r--r-- | Lib/tracemalloc.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Lib/tracemalloc.py b/Lib/tracemalloc.py index 6f0a234..adedfc5 100644 --- a/Lib/tracemalloc.py +++ b/Lib/tracemalloc.py @@ -1,4 +1,4 @@ -from collections import Sequence +from collections import Sequence, Iterable from functools import total_ordering import fnmatch import linecache @@ -119,12 +119,12 @@ def _compare_grouped_stats(old_group, new_group): previous = old_group.pop(traceback, None) if previous is not None: stat = StatisticDiff(traceback, - stat.size, stat.size - previous.size, - stat.count, stat.count - previous.count) + stat.size, stat.size - previous.size, + stat.count, stat.count - previous.count) else: stat = StatisticDiff(traceback, - stat.size, stat.size, - stat.count, stat.count) + stat.size, stat.size, + stat.count, stat.count) statistics.append(stat) for traceback, stat in old_group.items(): @@ -141,6 +141,7 @@ class Frame: __slots__ = ("_frame",) def __init__(self, frame): + # frame is a tuple: (filename: str, lineno: int) self._frame = frame @property @@ -177,6 +178,8 @@ class Traceback(Sequence): def __init__(self, frames): Sequence.__init__(self) + # frames is a tuple of frame tuples: see Frame constructor for the + # format of a frame tuple self._frames = frames def __len__(self): @@ -241,6 +244,8 @@ class Trace: __slots__ = ("_trace",) def __init__(self, trace): + # trace is a tuple: (size, traceback), see Traceback constructor + # for the format of the traceback tuple self._trace = trace @property @@ -268,6 +273,7 @@ class Trace: class _Traces(Sequence): def __init__(self, traces): Sequence.__init__(self) + # traces is a tuple of trace tuples: see Trace constructor self._traces = traces def __len__(self): @@ -338,6 +344,8 @@ class Snapshot: """ def __init__(self, traces, traceback_limit): + # traces is a tuple of trace tuples: see _Traces constructor for + # the exact format self.traces = _Traces(traces) self.traceback_limit = traceback_limit @@ -374,6 +382,9 @@ class Snapshot: is a list of Filter instances. If filters is an empty list, return a new Snapshot instance with a copy of the traces. """ + if not isinstance(filters, Iterable): + raise TypeError("filters must be a list of filters, not %s" + % type(filters).__name__) if filters: include_filters = [] exclude_filters = [] |