-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
PyBytes_Concat could try to concat in-place #65576
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
Comments
Currently, PyBytes_Concat always creates a new bytes object for the result. However, when Py_REFCNT(*pv) == 1, it could instead call _PyBytes_Resize() and then concat the second argument in place. (like e.g. _PyUnicode_Append does) |
Tentative patch attached. The test suite still passes, but I'm not sure if it actually exerts the new code path. Is there a standard way to test the C api? |
A quick grep shows me that it should be exercised at least by Modules/_io/bufferedio.c. |
If I remember correctly, ceval.c has an optmisation for str += str even if |
The latter, IMO. This issue is about the C API _PyBytes_Concat. |
Thanks! The latest patch looks fine to me. |
New changeset 4ed1b6c7e2f3 by Antoine Pitrou in branch 'default': |
New changeset 6234f4caba57 by Zachary Ware in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: