mirror of
https://github.com/python/cpython.git
synced 2026-01-08 08:22:41 +00:00
Revise the interface to the profiling and tracing support for the
Python interpreter. This change adds two new C-level APIs: PyEval_SetProfile() and PyEval_SetTrace(). These can be used to install profile and trace functions implemented in C, which can operate at much higher speeds than Python-based functions. The overhead for calling a C-based profile function is a very small fraction of a percent of the overhead involved in calling a Python-based function. The machinery required to call a Python-based profile or trace function been moved to sysmodule.c, where sys.setprofile() and sys.setprofile() simply become users of the new interface. As a side effect, SF bug #436058 is fixed; there is no longer a _PyTrace_Init() function to declare.
This commit is contained in:
parent
55fb6e0371
commit
5755ce693d
3 changed files with 182 additions and 150 deletions
|
|
@ -120,8 +120,10 @@ PyThreadState_New(PyInterpreterState *interp)
|
|||
tstate->exc_value = NULL;
|
||||
tstate->exc_traceback = NULL;
|
||||
|
||||
tstate->sys_profilefunc = NULL;
|
||||
tstate->sys_tracefunc = NULL;
|
||||
tstate->c_profilefunc = NULL;
|
||||
tstate->c_tracefunc = NULL;
|
||||
tstate->c_profileobj = NULL;
|
||||
tstate->c_traceobj = NULL;
|
||||
|
||||
HEAD_LOCK();
|
||||
tstate->next = interp->tstate_head;
|
||||
|
|
@ -152,8 +154,10 @@ PyThreadState_Clear(PyThreadState *tstate)
|
|||
ZAP(tstate->exc_value);
|
||||
ZAP(tstate->exc_traceback);
|
||||
|
||||
ZAP(tstate->sys_profilefunc);
|
||||
ZAP(tstate->sys_tracefunc);
|
||||
tstate->c_profilefunc = NULL;
|
||||
tstate->c_tracefunc = NULL;
|
||||
ZAP(tstate->c_profileobj);
|
||||
ZAP(tstate->c_traceobj);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue