def statistics(self, key_type, cumulative=False):
Group statistics by key_type. Return a sorted list of Statistic
grouped = self._group_by(key_type, cumulative)
statistics = list(grouped.values())
statistics.sort(reverse=True, key=Statistic._sort_key)
def compare_to(self, old_snapshot, key_type, cumulative=False):
Compute the differences with an old snapshot old_snapshot. Get
statistics as a sorted list of StatisticDiff instances, grouped by
new_group = self._group_by(key_type, cumulative)
old_group = old_snapshot._group_by(key_type, cumulative)
statistics = _compare_grouped_stats(old_group, new_group)
statistics.sort(reverse=True, key=StatisticDiff._sort_key)
Take a snapshot of traces of memory blocks allocated by Python.
raise RuntimeError("the tracemalloc module must be tracing memory "
"allocations to take a snapshot")
traceback_limit = get_traceback_limit()
return Snapshot(traces, traceback_limit)