aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-06-17 12:39:28 +0200
committerChristian Tismer <tismer@stackless.com>2022-06-17 13:27:17 +0200
commitb111cde848e3d8938be6214a4d377867753f4913 (patch)
tree4dc9b8f568fac64becf1c00bf173d8285f7956b3 /sources
parent69293f068e98f428df7226fe622fdeff6dd6f891 (diff)
PySide: speedup all cleanup calls by using PyName for staticMetaObject
This was found when debugging attribute access for improving PyEnum (the upcoming Enum Strict patch with forgiving fallback). It provides a quick shortcut for checking attribute names without string generation. Task-number: PYSide-1735 Change-Id: I765016a5a0f13e59cef85f57deebebd456b16a77 Pick-to: 6.3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside6/libpyside/pysidestaticstrings.h37
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp3
2 files changed, 21 insertions, 19 deletions
diff --git a/sources/pyside6/libpyside/pysidestaticstrings.h b/sources/pyside6/libpyside/pysidestaticstrings.h
index b106425e4..5180ac5b8 100644
--- a/sources/pyside6/libpyside/pysidestaticstrings.h
+++ b/sources/pyside6/libpyside/pysidestaticstrings.h
@@ -5,32 +5,33 @@
#define PYSIDESTRINGS_H
#include <sbkpython.h>
+#include <pysidemacros.h>
namespace PySide
{
namespace PyName
{
-PyObject *qtStaticMetaObject();
-PyObject *qtConnect();
-PyObject *qtDisconnect();
-PyObject *qtEmit();
-PyObject *dict_ring();
-PyObject *fset();
-PyObject *im_func();
-PyObject *im_self();
-PyObject *name();
-PyObject *parameters();
-PyObject *property();
-PyObject *select_id();
+PYSIDE_API PyObject *qtStaticMetaObject();
+PYSIDE_API PyObject *qtConnect();
+PYSIDE_API PyObject *qtDisconnect();
+PYSIDE_API PyObject *qtEmit();
+PYSIDE_API PyObject *dict_ring();
+PYSIDE_API PyObject *fset();
+PYSIDE_API PyObject *im_func();
+PYSIDE_API PyObject *im_self();
+PYSIDE_API PyObject *name();
+PYSIDE_API PyObject *parameters();
+PYSIDE_API PyObject *property();
+PYSIDE_API PyObject *select_id();
} // namespace PyName
namespace PyMagicName
{
-PyObject *code();
-PyObject *doc();
-PyObject *func();
-PyObject *get();
-PyObject *name();
-PyObject *property_methods();
+PYSIDE_API PyObject *code();
+PYSIDE_API PyObject *doc();
+PYSIDE_API PyObject *func();
+PYSIDE_API PyObject *get();
+PYSIDE_API PyObject *name();
+PYSIDE_API PyObject *property_methods();
} // namespace PyMagicName
} // namespace PySide
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 1c3976e00..fb2ec9532 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -6483,6 +6483,7 @@ bool CppGenerator::finishGeneration()
s << R"(#include <pysidecleanup.h>
#include <pysideqenum.h>
#include <feature_select.h>
+#include <pysidestaticstrings.h>
)";
}
@@ -6532,7 +6533,7 @@ bool CppGenerator::finishGeneration()
<< "for (int i = 0, imax = SBK_" << moduleName()
<< "_IDX_COUNT; i < imax; i++) {\n" << indent
<< "PyObject *pyType = reinterpret_cast<PyObject *>(" << cppApiVariableName() << "[i]);\n"
- << "Shiboken::AutoDecRef attrName(Py_BuildValue(\"s\", \"staticMetaObject\"));\n"
+ << "PyObject *attrName = PySide::PyName::qtStaticMetaObject();\n"
<< "if (pyType && PyObject_HasAttr(pyType, attrName))\n" << indent
<< "PyObject_SetAttr(pyType, attrName, Py_None);\n" << outdent
<< outdent << "}\n" << outdent << "}\n";