summaryrefslogtreecommitdiffstats
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-04-16 18:55:50 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-04-16 18:55:50 (GMT)
commit19ab6c98cf0525682b74f1f217503c42bacb4916 (patch)
tree085bf98c3a76a80475ef8864ac329c820286ad04 /Modules/_lsprof.c
parentd18d5a31535f4162045ce7b7ac8ea320333d24d4 (diff)
downloadcpython-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.c10
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;
}