Skip to content

gh-155742: Use PyBytesWriter in zlib - #157348

Draft
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:zlib_writer
Draft

gh-155742: Use PyBytesWriter in zlib#157348
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:zlib_writer

Conversation

@vstinner

@vstinner vstinner commented Sep 12, 2026

Copy link
Copy Markdown
Member

Replace soft deprecated _PyBytes_Resize() with PyBytesWriter.

Replace soft deprecated _PyBytes_Resize() with PyBytesWriter.
@vstinner

Copy link
Copy Markdown
Member Author

I marked the PR as a draft since benchmarks should be run on this change.

_PyBytes_Resize(n) allocates exactly n bytes, whereas PyBytesWriter_Resize(n) overallocates the buffer.

See also PR gh-139976 which modified _bz2, _lzma, _zstd and zlib extensions to use PyBytesWriter (in pycore_blocks_output_buffer.h).

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