Skip to content

Commit 378e86a

Browse files
committed
repr string building with mutex
1 parent 4b25029 commit 378e86a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

quaddtype/numpy_quaddtype/src/scalar.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ QuadPrecision_repr(QuadPrecisionObject *self)
215215
static PyObject *
216216
QuadPrecision_repr_dragon4(QuadPrecisionObject *self)
217217
{
218+
#ifdef Py_GIL_DISABLED
219+
PyMutex_Lock(&scalar_mutex);
220+
#endif
218221
Dragon4_Options opt = {.scientific = 1,
219222
.digit_mode = DigitMode_Unique,
220223
.cutoff_mode = CutoffMode_TotalLength,
@@ -244,6 +247,9 @@ QuadPrecision_repr_dragon4(QuadPrecisionObject *self)
244247
const char *backend_str = (self->backend == BACKEND_SLEEF) ? "sleef" : "longdouble";
245248
PyObject *res = PyUnicode_FromFormat("QuadPrecision('%S', backend='%s')", str, backend_str);
246249
Py_DECREF(str);
250+
#ifdef Py_GIL_DISABLED
251+
PyMutex_Unlock(&scalar_mutex);
252+
#endif
247253
return res;
248254
}
249255

0 commit comments

Comments
 (0)