From 91698d8caa4b5bb6e8dbb64b156e8afe9e32cac1 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2020 14:07:40 +0200 Subject: bpo-40521: Optimize PyBytes_FromStringAndSize(str, 0) (GH-21142) Always create the empty bytes string singleton. Optimize PyBytes_FromStringAndSize(str, 0): it no longer has to check if the empty string singleton was created or not, it is always available. Add functions: * _PyBytes_Init() * bytes_get_empty(), bytes_new_empty() * bytes_create_empty_string_singleton() * unicode_create_empty_string_singleton() _Py_unicode_state: rename empty structure member to empty_string. --- Python/pylifecycle.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Python/pylifecycle.c') diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 4b658f847b..cd993ea134 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -607,6 +607,11 @@ pycore_init_types(PyThreadState *tstate) return status; } + status = _PyBytes_Init(tstate); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + status = _PyExc_Init(tstate); if (_PyStatus_EXCEPTION(status)) { return status; -- cgit v1.2.1