summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-23 13:54:35 (GMT)
committerGitHub <noreply@github.com>2020-06-23 13:54:35 (GMT)
commitc41eed1a874e2f22bde45c3c89418414b7a37f46 (patch)
treee90ff0bf1c5349169f3f04c914695b3c4b476f37 /Include
parent32f2eda85957365d208f499b730d30b7eb419741 (diff)
downloadcpython-c41eed1a874e2f22bde45c3c89418414b7a37f46.zip
cpython-c41eed1a874e2f22bde45c3c89418414b7a37f46.tar.gz
cpython-c41eed1a874e2f22bde45c3c89418414b7a37f46.tar.bz2
bpo-40521: Make bytes singletons per interpreter (GH-21074)
Each interpreter now has its own empty bytes string and single byte character singletons. Replace STRINGLIB_EMPTY macro with STRINGLIB_GET_EMPTY() macro.
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_interp.h6
-rw-r--r--Include/internal/pycore_pylifecycle.h2
2 files changed, 7 insertions, 1 deletions
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 697d97a..64e891f 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -65,6 +65,11 @@ struct _Py_unicode_fs_codec {
_Py_error_handler error_handler;
};
+struct _Py_bytes_state {
+ PyBytesObject *characters[256];
+ PyBytesObject *empty_string;
+};
+
struct _Py_unicode_state {
struct _Py_unicode_fs_codec fs_codec;
};
@@ -233,6 +238,7 @@ struct _is {
*/
PyLongObject* small_ints[_PY_NSMALLNEGINTS + _PY_NSMALLPOSINTS];
#endif
+ struct _Py_bytes_state bytes;
struct _Py_unicode_state unicode;
struct _Py_float_state float_state;
/* Using a cache is very effective since typically only a single slice is
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index 83ce1d2..9a3063a 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -63,7 +63,7 @@ extern void _PyDict_Fini(PyThreadState *tstate);
extern void _PyTuple_Fini(PyThreadState *tstate);
extern void _PyList_Fini(PyThreadState *tstate);
extern void _PySet_Fini(PyThreadState *tstate);
-extern void _PyBytes_Fini(void);
+extern void _PyBytes_Fini(PyThreadState *tstate);
extern void _PyFloat_Fini(PyThreadState *tstate);
extern void _PySlice_Fini(PyThreadState *tstate);
extern void _PyAsyncGen_Fini(PyThreadState *tstate);