from tracemalloc import Statistic, _compare_grouped_stats
old = {"a": Statistic("a", 100, 2), "b": Statistic("b", 50, 1)}
new = {"a": Statistic("a", 200, 3), "c": Statistic("c", 10, 1)}
old_copy = dict(old)
_compare_grouped_stats(old, new)
print(len(old), len(old_copy)) # 1 2
Two small issues in Lib/tracemalloc.py:
_compare_grouped_stats() mutates its old_group argument by popping
keys from it. After the call, old_group is missing every key that
was also in new_group.
A typo in the error message raised by _group_by():
"cumulative mode cannot by used" should be
"cumulative mode cannot be used".
Reproduction for (1):
Linked PRs
tracemalloccumulative mode error message #158233