Support option to avoid printing duplicate values
rogpeppe opened this issue · comments
Currently if there are multiple references to a pointer, the entire contents of it are printed each time (unless it's a recursive reference).
This can result in unnecessarily large and hard to read output when an object is shared in many places.
In one recent example, the output was 28MB, but when I changed the code to avoid printing duplicates (by removing the delete(d.pointers, k)
line), the output dropped to 280KB, a factor of 100x difference.
This is not necessarily something that would be a good idea to enable by default, because it would require using O(n) memory to keep track of all pointers seen so far, but ISTM that it would be nice to be able to enable de-duplication as an option, at any rate.