[Python-Dev] [Python-checkins] cpython: Close #19762: Fix name of _get_traces() and _get_object_traceback() function (original) (raw)
Victor Stinner victor.stinner at gmail.com
Mon Nov 25 16:23:22 CET 2013
- Previous message: [Python-Dev] [Python-checkins] cpython: Close #19762: Fix name of _get_traces() and _get_object_traceback() function
- Next message: [Python-Dev] potential argparse problem: bad mix of parse_known_args and prefix matching
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2013/11/25 Jim Jewett <jimjjewett at gmail.com>:
Why are these functions (gettraces and getobjecttraceback) private?
_get_object_traceback() is wrapped to get a nice Python object: http://hg.python.org/cpython/file/6ec6facb69ca/Lib/tracemalloc.py#l208
_get_traces() is private, it is used internally by take_snapshot(): http://hg.python.org/cpython/file/6ec6facb69ca/Lib/tracemalloc.py#l455
So it's possible to modify the low-level (private) structure used in the C module without touching the high-level (public) Python API.
(1) Is the whole module provisional? At one point, I had thought so, but I don't see that in the PEP or implementation. (I'm not sure that it should be provisional, but I want to be sure that the decision is intentional.)
I don't know.
(2) This implementation does lock in certain choices about the nature of traces. (What data to include for analysis vs excluding to save memory; which events are tracked separately and which combined into a single total; organizing the data that is saved in a hash by certain keys; etc)
While I would prefer more flexibility, the existing code provides a reasonable default, and I can't forsee changing traces so much that these functions can't be reasonably supported unless the rest of the module API changes too.
Sorry, I don't see which kind of information is "excluded" to save memory.
Maybe you read an old version of the PEP?
About "events": tracemalloc doesn't store functions calls as event, there is no timestamp. I didn't try to implement that, and I doesn't want to. If you develop it (maybe on top of tracemalloc, I mean by modify _tracemalloc.c), I would be interested to see your code and test it :-)
(3) getobjecttraceback is the killer app that justifies the specific data-collection choices Victor made; if it isn't public, the implementation starts to look overbuilt.
It is public, see the doc and the doc: http://docs.python.org/dev/library/tracemalloc.html#tracemalloc.get_object_traceback http://www.python.org/dev/peps/pep-0454/
(4) gettraces is about the only way to get at even the all the data that is stored, prior to additional summarization. If it isn't public, those default summarization options become even more locked in..
Snapshot.traces contains exactly the same data than _get_traces().
In a previous version of the PEP/code, statistics were computed while traces were collected. It's not more the case. Now the API only collect raw data, and then you have call to Snapshot.statistics() or Snapshot.compare_to().
Victor
- Previous message: [Python-Dev] [Python-checkins] cpython: Close #19762: Fix name of _get_traces() and _get_object_traceback() function
- Next message: [Python-Dev] potential argparse problem: bad mix of parse_known_args and prefix matching
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]