From 37a1e27d49a6a1f7e45621e93a0f13a63fb20d9e Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 5 Dec 2019 11:08:50 +0100 Subject: Optimize the Python 3.8 refcount fix a tiny bit This change uses the fact that our workaround to temporarily remove the Py_TPFLAGS_METHOD_DESCRIPTOR flag uses the "mro" function of PyType_Type, which never will change. Therefore, the static keyword makes sure that this function lookup happens only once. Change-Id: I44b74556da1fac2596c81339af30cb66218276e2 Reviewed-by: Friedemann Kleint --- sources/shiboken2/libshiboken/basewrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index 4030fe1c4..dd5dc43e9 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -506,7 +506,7 @@ PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *k // PYSIDE-939: This is a temporary patch that circumvents the problem // with Py_TPFLAGS_METHOD_DESCRIPTOR until this is finally solved. PyObject *ob_PyType_Type = reinterpret_cast(&PyType_Type); - PyObject *mro = PyObject_GetAttr(ob_PyType_Type, Shiboken::PyName::mro()); + static PyObject *mro = PyObject_GetAttr(ob_PyType_Type, Shiboken::PyName::mro()); auto hold = Py_TYPE(mro)->tp_flags; Py_TYPE(mro)->tp_flags &= ~Py_TPFLAGS_METHOD_DESCRIPTOR; auto *newType = reinterpret_cast(type_new(metatype, args, kwds)); -- cgit v1.2.3