MCPcopy Index your code
hub / github.com/python/cpython / filter_traces

Method filter_traces

Lib/tracemalloc.py:452–475  ·  view source on GitHub ↗

Create a new Snapshot instance with a filtered traces sequence, filters is a list of Filter or DomainFilter instances. If filters is an empty list, return a new Snapshot instance with a copy of the traces.

(self, filters)

Source from the content-addressed store, hash-verified

450 return True
451
452 def filter_traces(self, filters):
453 """
454 Create a new Snapshot instance with a filtered traces sequence, filters
455 is a list of Filter or DomainFilter instances. If filters is an empty
456 list, return a new Snapshot instance with a copy of the traces.
457 """
458 if not isinstance(filters, Iterable):
459 raise TypeError("filters must be a list of filters, not %s"
460 % type(filters).__name__)
461 if filters:
462 include_filters = []
463 exclude_filters = []
464 for trace_filter in filters:
465 if trace_filter.inclusive:
466 include_filters.append(trace_filter)
467 else:
468 exclude_filters.append(trace_filter)
469 new_traces = [trace for trace in self.traces._traces
470 if self._filter_trace(include_filters,
471 exclude_filters,
472 trace)]
473 else:
474 new_traces = self.traces._traces.copy()
475 return Snapshot(new_traces, self.traceback_limit)
476
477 def _group_by(self, key_type, cumulative):
478 if key_type not in ('traceback', 'filename', 'lineno'):

Callers 4

test_filter_tracesMethod · 0.80
get_traced_memoryMethod · 0.80

Calls 4

_filter_traceMethod · 0.95
SnapshotClass · 0.85
appendMethod · 0.45
copyMethod · 0.45

Tested by 4

test_filter_tracesMethod · 0.64
get_traced_memoryMethod · 0.64