aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-25 14:07:40 +0200
committerGitHub <noreply@github.com>2020-06-25 14:07:40 +0200
commit91698d8caa4b5bb6e8dbb64b156e8afe9e32cac1 (patch)
treeafe2af94e5cf72cc28d405ae2c30dcb2210e52ea /Python/pylifecycle.c
parentbpo-41113: Fix test_warnings on non-Western locales. (GH-21143) (diff)
downloadcpython-91698d8caa4b5bb6e8dbb64b156e8afe9e32cac1.tar.gz
cpython-91698d8caa4b5bb6e8dbb64b156e8afe9e32cac1.tar.bz2
cpython-91698d8caa4b5bb6e8dbb64b156e8afe9e32cac1.zip
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.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 4b658f847bc..cd993ea1341 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;