Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-129813: Enhance PyBytesWriter documentation
Mention if functions overallocate or not.
  • Loading branch information
vstinner committed Oct 15, 2025
commit 751c2d0cf977e85317f06326c2ec84e410ba0c52
5 changes: 3 additions & 2 deletions Doc/c-api/bytes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ Create, Finish, Discard

If *size* is greater than zero, allocate *size* bytes, and set the
writer size to *size*. The caller is responsible to write *size*
bytes using :c:func:`PyBytesWriter_GetData`.
bytes using :c:func:`PyBytesWriter_GetData`. Do not overallocate.
Comment thread
vstinner marked this conversation as resolved.
Outdated

On error, set an exception and return ``NULL``.

Expand Down Expand Up @@ -348,7 +348,7 @@ Low-level API
.. c:function:: int PyBytesWriter_Resize(PyBytesWriter *writer, Py_ssize_t size)

Resize the writer to *size* bytes. It can be used to enlarge or to
shrink the writer.
shrink the writer. Overallocate the writer.
Comment thread
vstinner marked this conversation as resolved.
Outdated

Newly allocated bytes are left uninitialized.

Expand All @@ -360,6 +360,7 @@ Low-level API
.. c:function:: int PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t grow)

Resize the writer by adding *grow* bytes to the current writer size.
Overallocate the writer.
Comment thread
vstinner marked this conversation as resolved.
Outdated

Newly allocated bytes are left uninitialized.

Expand Down
Loading