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

Ethan Furman ethan at stoneleaf.us
Thu Oct 31 15:32:42 CET 2013


On 10/31/2013 05:20 AM, Victor Stinner wrote:

I did another experiment. I replaced enable/disable/isenabled with start/stop/istracing, and added enable/disable/isenabled functions to disable temporarily tracing.

API: - cleartraces(): clear traces - start(): start tracing (the old "enable") - stop(): stop tracing and clear traces (the old "disable") - disable(): disable temporarily tracing - enable(): reenable tracing - istracing(): True if tracemalloc is tracing, False otherwise (the old "isenabled") - isenabled(): True if tracemalloc is enabled, False otherwise

These names make more sense. However, stop is still misleading as it both stops and destroys data. An easy fix for that is for stop to save the data somewhere so get_traces (or whatever) can still retrieve it.

If stop really must destroy the data, perhaps it should be called close instead; StringIO has a similar close method that when called destroys any stored data, and get_value must be called first if that data is wanted.

-- Ethan



More information about the Python-Dev mailing list