Skip to content

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commented Jun 25, 2020

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 member to empty_string

https://bugs.python.org/issue40521

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 member to empty_string
@vstinner
Copy link
MemberAuthor

This PR fix STRINGLIB_GET_EMPTY(): STRINGLIB_GET_EMPTY() result must not be NULL.

@vstinnervstinner merged commit 91698d8 into python:masterJun 25, 2020
@vstinnervstinner deleted the bytes_empty_string branch June 25, 2020 12:07
fasih pushed a commit to fasih/cpython that referenced this pull request Jun 29, 2020
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.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@vstinner@the-knights-who-say-ni@bedevere-bot