Mercurial > cpython-lru_cache-weakref
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 18134:eff8da7c3dcb | 18136:4cb34314bd97 |
|---|---|
| 194 static char setdefaultencoding_doc[] = | 194 static char setdefaultencoding_doc[] = |
| 195 "setdefaultencoding(encoding)\n\ | 195 "setdefaultencoding(encoding)\n\ |
| 196 \n\ | 196 \n\ |
| 197 Set the current default string encoding used by the Unicode implementation."; | 197 Set the current default string encoding used by the Unicode implementation."; |
| 198 | 198 |
| 199 extern int _PyTrace_Init(void); | |
| 200 | |
| 199 static PyObject * | 201 static PyObject * |
| 200 sys_settrace(PyObject *self, PyObject *args) | 202 sys_settrace(PyObject *self, PyObject *args) |
| 201 { | 203 { |
| 202 PyThreadState *tstate = PyThreadState_Get(); | 204 PyThreadState *tstate = PyThreadState_Get(); |
| 205 if (_PyTrace_Init() == -1) | |
| 206 return NULL; | |
| 203 if (args == Py_None) | 207 if (args == Py_None) |
| 204 args = NULL; | 208 args = NULL; |
| 205 else | 209 else |
| 206 Py_XINCREF(args); | 210 Py_XINCREF(args); |
| 207 Py_XDECREF(tstate->sys_tracefunc); | 211 Py_XDECREF(tstate->sys_tracefunc); |
| 218 | 222 |
| 219 static PyObject * | 223 static PyObject * |
| 220 sys_setprofile(PyObject *self, PyObject *args) | 224 sys_setprofile(PyObject *self, PyObject *args) |
| 221 { | 225 { |
| 222 PyThreadState *tstate = PyThreadState_Get(); | 226 PyThreadState *tstate = PyThreadState_Get(); |
| 227 if (_PyTrace_Init() == -1) | |
| 228 return NULL; | |
| 223 if (args == Py_None) | 229 if (args == Py_None) |
| 224 args = NULL; | 230 args = NULL; |
| 225 else | 231 else |
| 226 Py_XINCREF(args); | 232 Py_XINCREF(args); |
| 227 Py_XDECREF(tstate->sys_profilefunc); | 233 Py_XDECREF(tstate->sys_profilefunc); |
