> Snapshot > -------- > > ``Snapshot(timestamp: datetime.datetime, traceback_limit: int, stats: > dict=None, traces: dict=None)`` class: > > Snapshot of statistics and traces of memory blocks allocated by > Python. > > ``apply_filters(filters)`` method: > > Apply filters on the ``traces`` and ``stats`` dictionaries, > *filters* is a list of ``Filter`` instances.
Snapshot.apply_filters() currently works in-place. This is not convinient. It should create a new Snapshot instance. For example, I have a huge snapshot with +800K traces. I would like to ignore <unknown> and <frozen importlib._bootrap> filenames: I apply a first filter to exclude <*>. Then I only want to see allocations related to the regular expressions: I apply a second pair of filters to only include */sre*.py and */re.py. Ok, now I want to see other files. Uh oh, I loose all others traces, I have to reload the huge snapshot. And again, exclude <*>. I would prefer something like: full_snapshot = Snapshot.load("huge.pickle") clean = full_snapshot.apply_filters([Filter(False, "<*>")]) # delete maybe full_snapshot here regex = clean.apply_filters([Filter(True, "*/re.py"), Filter(True, "*/sre*.py")]) other = clean.apply_filters([Filter(False, "*/re.py"), Filter(False, "*/sre*.py")]) ... > ``Filter(include: bool, filename_pattern: str, lineno: int=None, > traceback: bool=False)`` class: > ... > ``traceback`` attribute: > > If *traceback* is ``True``, all frames of the traceback are checked. > If *traceback* is ``False``, only the most recent frame is checked. > > This attribute is ignored if the traceback limit is less than ``2``. > See the ``get_traceback_limit()`` function. Hum, I don't really like the traceback name. traceback=False is confusing because the traceback is used by the filter even if traceback=False. Other names: all_frames, any_frame, most_recent_frame_only, ...? Example: f1 = Filter("*/linecache.py", all_frames=True) f2 = Filter("*/linecache.py") # all_frames is False by default Victor _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com