[Python-Dev] PEP 454 (tracemalloc) disable ==> clear?

Victor Stinner victor.stinner at gmail.com
Wed Oct 30 11:09:30 CET 2013


2013/10/30 Stephen J. Turnbull <stephen at xemacs.org>:
> Just "reset" implies to me that you're ready to start over.  Not just
> traced memory blocks but accumulated statistics and any configuration
> (such as Filters) would also be reset.  Also tracing would be disabled
> until started explicitly.

If the name is really the problem, I propose the restore the previous
name: clear_traces(). It's symmetric with get_traces(), like
add_filter()/get_filters()/clear_filters().


> Shouldn't disable() do this automatically, perhaps with an optional
> discard_traces flag (which would be False by default)?

The pattern is something like that:

enable()
snapshot1 = take_snapshot()
...
snapshot2 = take_snapshot()
disable()

I don't see why disable() would return data.


> But I definitely agree with Jim:  You *must* provide an example here
> showing how to save the traces (even though it's trivial to do so),
> because that will make clear that disable() is a destructive
> operation.  (It is not destructive in any other debugging tool that
> I've used.)  Even with documentation, be prepared for user complaints.

I added "Call get_traces() or take_snapshot() function to get traces
before clearing them." to the doc:

http://www.haypocalc.com/tmp/tracemalloc/library/tracemalloc.html#tracemalloc.disable

Victor


More information about the Python-Dev mailing list