Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 12, 2025

Replace PyBytes_FromStringAndSize(NULL, size) with the new public PyBytesWriter API.

Replace PyBytes_FromStringAndSize(NULL, size) with the new public
PyBytesWriter API.
@vstinner
Copy link
Member Author

Microbenchmark on bytes + bytes:

python -m pyperf timeit -s 'a=b"a"; b=b"b"' 'a+b'

Result: Mean +- std dev: [ref] 38.0 ns +- 1.1 ns -> [pep782] 52.7 ns +- 1.7 ns: 1.39x slower.

Oh, this change has a significant impact on performance. I prefer to abandon it.

@vstinner vstinner closed this Sep 13, 2025
@vstinner vstinner deleted the pybyteswriter_bytes_concat branch September 13, 2025 17:05
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.

1 participant