Skip to content

gh-129813, PEP 782: Use PyBytesWriter in bufferedio.c - #139121

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:pybyteswriter_buffered_read
Sep 18, 2025
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:pybyteswriter_buffered_read

Conversation

@vstinner

@vstinner vstinner commented Sep 18, 2025 •

Copy link
Copy Markdown
Member

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

Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.
@vstinner

vstinner commented Sep 18, 2025 •

Copy link
Copy Markdown
Member Author

cc @cmaloney

Sadly, it's hard to write a benchmark for this C function (_bufferedreader_read_generic()), since the io module reads more data than requested and then cache it. Following file.read() calls will call _bufferedreader_read_fast() instead.

@vstinner
vstinner merged commit 9b35f7c into python:main Sep 18, 2025
@vstinner
vstinner deleted the pybyteswriter_buffered_read branch September 18, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant