Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create per-interpreter intern dict after init of deep-frozen modules
  • Loading branch information
encukou committed Aug 16, 2024
commit 1b8c12eb4ae04f9f799f372aaf49712fff0ebf6d
3 changes: 2 additions & 1 deletion Include/internal/pycore_unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ extern "C" {

#include "pycore_fileutils.h" // _Py_error_handler
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
#include "pycore_global_objects.h" // _Py_SINGLETON

void _PyUnicode_ExactDealloc(PyObject *op);
Py_ssize_t _PyUnicode_InternedSize(void);
Py_ssize_t _PyUnicode_InternedSize_Immortal(void);

/* runtime lifecycle */

extern void _PyUnicode_InitState(PyInterpreterState *);
extern PyStatus _PyUnicode_InitGlobalObjects(PyInterpreterState *);
extern PyStatus _PyUnicode_InitInternDict(PyInterpreterState *);
extern PyStatus _PyUnicode_InitTypes(PyInterpreterState *);
extern void _PyUnicode_Fini(PyInterpreterState *);
extern void _PyUnicode_FiniTypes(PyInterpreterState *);
Expand Down
9 changes: 9 additions & 0 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -14844,6 +14844,15 @@ _PyUnicode_InitGlobalObjects(PyInterpreterState *interp)
}
assert(INTERNED_STRINGS);

return _PyStatus_OK();
}


PyStatus
_PyUnicode_InitInternDict(PyInterpreterState *interp)
{
assert(INTERNED_STRINGS);

if (init_interned_dict(interp)) {
PyErr_Clear();
return _PyStatus_ERR("failed to create interned dict");
Expand Down
7 changes: 7 additions & 0 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,13 @@ pycore_interp_init(PyThreadState *tstate)
return _PyStatus_ERR("failed to initialize deep-frozen modules");
}

// Per-interpreter interned string dict is created after deep-frozen
// modules have interned the global strings.
status = _PyUnicode_InitInternDict(interp);
if (_PyStatus_EXCEPTION(status)) {
return status;
}

status = pycore_init_types(interp);
if (_PyStatus_EXCEPTION(status)) {
goto done;
Expand Down