summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-07-08 17:47:37 (GMT)
committerGitHub <noreply@github.com>2022-07-08 17:47:37 (GMT)
commit9dff9f48144cf5d8bc1e6605f258973200c6b8c8 (patch)
treef5c278b5a4b4256b19eb53aaac4873fe258d225c /Objects
parentbe862b4e55cfe3413752aba2437f9086b5315d08 (diff)
downloadcpython-9dff9f48144cf5d8bc1e6605f258973200c6b8c8.zip
cpython-9dff9f48144cf5d8bc1e6605f258973200c6b8c8.tar.gz
cpython-9dff9f48144cf5d8bc1e6605f258973200c6b8c8.tar.bz2
GH-90699: Intern statically allocated strings (GH-93597)
This is similar to how strings are interned for deepfreeze.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index d0e4bcd..669ffe7 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -52,6 +52,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "pycore_pathconfig.h" // _Py_DumpPathConfig()
#include "pycore_pylifecycle.h" // _Py_SetFileSystemEncoding()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
+#include "pycore_runtime_init.h" // _PyUnicode_InitStaticStrings()
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
#include "pycore_unicodeobject.h" // struct _Py_unicode_state
#include "stringlib/eq.h" // unicode_eq()
@@ -14576,6 +14577,14 @@ _PyUnicode_InitGlobalObjects(PyInterpreterState *interp)
return _PyStatus_OK();
}
+ /* Intern statically allocated string identifiers and deepfreeze strings.
+ * This must be done before any module initialization so that statically
+ * allocated string identifiers are used instead of heap allocated strings.
+ * Deepfreeze uses the interned identifiers if present to save space
+ * else generates them and they are interned to speed up dict lookups.
+ */
+ _PyUnicode_InitStaticStrings();
+
#ifdef Py_DEBUG
assert(_PyUnicode_CheckConsistency(&_Py_STR(empty), 1));