diff options
author | Fred Drake <fdrake@acm.org> | 2001-06-16 21:02:31 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-06-16 21:02:31 (GMT) |
commit | d083839fb4f44ff66792d80f7a71863600ca4638 (patch) | |
tree | f57615d2bb6f241762afb0f5c5b15a40c908e386 /Python/sysmodule.c | |
parent | 70128a1ba693d399177714e657e13c08a2056b45 (diff) | |
download | cpython-d083839fb4f44ff66792d80f7a71863600ca4638.zip cpython-d083839fb4f44ff66792d80f7a71863600ca4638.tar.gz cpython-d083839fb4f44ff66792d80f7a71863600ca4638.tar.bz2 |
Instead of initializing & interning the strings passed to the profile
and trace functions lazily, which incurs extra argument pushing and checks
in the C overhead for profiling/tracing, create the strings semi-lazily
when the Python code first registers a profile or trace function. This
simplifies the trampoline into the profile/trace functions.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 52fbbc8..62e0841 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -196,10 +196,14 @@ static char setdefaultencoding_doc[] = \n\ Set the current default string encoding used by the Unicode implementation."; +extern int _PyTrace_Init(void); + static PyObject * sys_settrace(PyObject *self, PyObject *args) { PyThreadState *tstate = PyThreadState_Get(); + if (_PyTrace_Init() == -1) + return NULL; if (args == Py_None) args = NULL; else @@ -220,6 +224,8 @@ static PyObject * sys_setprofile(PyObject *self, PyObject *args) { PyThreadState *tstate = PyThreadState_Get(); + if (_PyTrace_Init() == -1) + return NULL; if (args == Py_None) args = NULL; else |