mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
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.
This commit is contained in:
parent
70128a1ba6
commit
d083839fb4
2 changed files with 48 additions and 26 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue