summaryrefslogtreecommitdiffstats
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
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 17c71e9..d665f83 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;
}