https://github.com/python/cpython/commit/4126d9f1ab682afeecdff624b1fd698c192bcb21
commit: 4126d9f1ab682afeecdff624b1fd698c192bcb21
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-10-15T14:54:18+02:00
summary:

gh-129813: Enhance PyBytesWriter documentation (#140152)

Co-authored-by: Antoine Pitrou <[email protected]>

files:
M Doc/c-api/bytes.rst

diff --git a/Doc/c-api/bytes.rst b/Doc/c-api/bytes.rst
index 9bddfe4dce2f87..865a9e5d2bf5d5 100644
--- a/Doc/c-api/bytes.rst
+++ b/Doc/c-api/bytes.rst
@@ -259,6 +259,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`.
+   This function does not overallocate.
 
    On error, set an exception and return ``NULL``.
 
@@ -349,6 +350,8 @@ Low-level API
 
    Resize the writer to *size* bytes. It can be used to enlarge or to
    shrink the writer.
+   This function typically overallocates to achieve amortized performance when
+   resizing multiple times.
 
    Newly allocated bytes are left uninitialized.
 
@@ -360,6 +363,8 @@ 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.
+   This function typically overallocates to achieve amortized performance when
+   resizing multiple times.
 
    Newly allocated bytes are left uninitialized.
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to