bpo-40521: Make empty Unicode string per interpreter (GH-21096)

Each interpreter now has its own empty Unicode string singleton.
This commit is contained in:
Victor Stinner 2020-06-24 00:10:40 +02:00 committed by GitHub
parent d051801052
commit f363d0a6e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 130 additions and 90 deletions

View file

@ -71,6 +71,8 @@ struct _Py_bytes_state {
};
struct _Py_unicode_state {
// The empty Unicode object is a singleton to improve performance.
PyObject *empty;
struct _Py_unicode_fs_codec fs_codec;
};

View file

@ -31,7 +31,7 @@ PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc);
/* Various one-time initializers */
extern PyStatus _PyUnicode_Init(void);
extern PyStatus _PyUnicode_Init(PyThreadState *tstate);
extern int _PyStructSequence_Init(void);
extern int _PyLong_Init(PyThreadState *tstate);
extern PyStatus _PyFaulthandler_Init(int enable);