Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 18136:4cb34314bd97 legacy-trunk
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.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Sat, 16 Jun 2001 21:02:31 +0000 |
| parents | beb9d2b02846 |
| children | 982163c4e9d2 |
line wrap: on
line diff
--- a/Python/sysmodule.c Sat Jun 16 08:48:40 2001 +0000 +++ b/Python/sysmodule.c Sat Jun 16 21:02:31 2001 +0000 @@ -196,10 +196,14 @@ \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 @@ sys_setprofile(PyObject *self, PyObject *args) { PyThreadState *tstate = PyThreadState_Get(); + if (_PyTrace_Init() == -1) + return NULL; if (args == Py_None) args = NULL; else
