diff options
Diffstat (limited to 'sources/shiboken6/libshiboken/sbkstring.cpp')
-rw-r--r-- | sources/shiboken6/libshiboken/sbkstring.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sources/shiboken6/libshiboken/sbkstring.cpp b/sources/shiboken6/libshiboken/sbkstring.cpp index 7fd20173c..36fe50369 100644 --- a/sources/shiboken6/libshiboken/sbkstring.cpp +++ b/sources/shiboken6/libshiboken/sbkstring.cpp @@ -5,8 +5,14 @@ #include "sbkstaticstrings_p.h" #include "autodecref.h" -#include <vector> -#include <unordered_set> +#if PY_VERSION_HEX >= 0x030B0000 || defined(Py_LIMITED_API) +# define USE_INTERN_STRINGS +#endif + +#ifndef USE_INTERN_STRINGS +# include <vector> +# include <unordered_set> +#endif namespace Shiboken::String { @@ -179,6 +185,13 @@ Py_ssize_t len(PyObject *str) // PyObject *attr = PyObject_GetAttr(obj, name()); // +#ifdef USE_INTERN_STRINGS +PyObject *createStaticString(const char *str) +{ + return PyUnicode_InternFromString(str); +} +#else + using StaticStrings = std::unordered_set<PyObject *>; static void finalizeStaticStrings(); // forward @@ -225,6 +238,8 @@ PyObject *createStaticString(const char *str) return result; } +#endif // !USE_INTERN_STRINGS + /////////////////////////////////////////////////////////////////////// // // PYSIDE-1019: Helper function for snake_case vs. camelCase names |