diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-04-16 18:55:50 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-04-16 18:55:50 (GMT) |
commit | 19ab6c98cf0525682b74f1f217503c42bacb4916 (patch) | |
tree | 085bf98c3a76a80475ef8864ac329c820286ad04 /Modules/_lsprof.c | |
parent | d18d5a31535f4162045ce7b7ac8ea320333d24d4 (diff) | |
download | cpython-19ab6c98cf0525682b74f1f217503c42bacb4916.zip cpython-19ab6c98cf0525682b74f1f217503c42bacb4916.tar.gz cpython-19ab6c98cf0525682b74f1f217503c42bacb4916.tar.bz2 |
Initialize structseq types only once.
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r-- | Modules/_lsprof.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index dddab8e..d35c894 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -515,6 +515,7 @@ static PyStructSequence_Desc profiler_subentry_desc = { 5 }; +static int initialized; static PyTypeObject StatsEntryType; static PyTypeObject StatsSubEntryType; @@ -857,8 +858,12 @@ init_lsprof(void) return; PyDict_SetItemString(d, "Profiler", (PyObject *)&PyProfiler_Type); - PyStructSequence_InitType(&StatsEntryType, &profiler_entry_desc); - PyStructSequence_InitType(&StatsSubEntryType, &profiler_subentry_desc); + if (!initialized) { + PyStructSequence_InitType(&StatsEntryType, + &profiler_entry_desc); + PyStructSequence_InitType(&StatsSubEntryType, + &profiler_subentry_desc); + } Py_INCREF((PyObject*) &StatsEntryType); Py_INCREF((PyObject*) &StatsSubEntryType); PyModule_AddObject(module, "profiler_entry", @@ -866,4 +871,5 @@ init_lsprof(void) PyModule_AddObject(module, "profiler_subentry", (PyObject*) &StatsSubEntryType); empty_tuple = PyTuple_New(0); + initialized = 1; } |