Skip to content

gh-158585: Don't overallocate at first PyBytesWriter_Resize() - #158616

Open
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:bytes_writer_resize
Open

vstinner wants to merge 1 commit into
python:mainfrom
vstinner:bytes_writer_resize

Conversation

@vstinner

@vstinner vstinner commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

PyBytesWriter_Resize() and PyBytesWriter_Grow() no longer overallocate when the first bytes/bytearray object is allocated. Only overallocate bytes objects at next PyBytesWriter_Resize() and PyBytesWriter_Grow() calls.

PyBytesWriter_Resize() and PyBytesWriter_Grow() no longer
overallocate when the first bytes/bytearray object is allocated.
Only overallocate bytes objects at next PyBytesWriter_Resize() and
PyBytesWriter_Grow() calls.
@vstinner

vstinner commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

See PR gh-158615 "io.BufferedReader.readline()" change. Combining the two PRs make io.BufferedReader.readline() up to 1.13x faster (but 1.05x in the corner cases of lines 10x longer than the io.BufferedReader buffer size).

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