Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-40521: Optimize PyBytes_FromStringAndSize(str, 0) #21142

Merged
merged 1 commit into from
Jun 25, 2020
Merged

bpo-40521: Optimize PyBytes_FromStringAndSize(str, 0) #21142

merged 1 commit into from
Jun 25, 2020

Conversation

vstinner
Copy link
Member

@vstinner vstinner 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
Member Author

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

@vstinner vstinner merged commit 91698d8 into python:master Jun 25, 2020
@vstinner vstinner 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.
arun-mani-j pushed a commit to arun-mani-j/cpython that referenced this pull request Jul 21, 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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants