Skip to content

Commit 4126d9f

Browse files
vstinnerpitrou
andauthored
gh-129813: Enhance PyBytesWriter documentation (#140152)
Co-authored-by: Antoine Pitrou <[email protected]>
1 parent 46f11b3 commit 4126d9f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Doc/c-api/bytes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ Create, Finish, Discard
259259
If *size* is greater than zero, allocate *size* bytes, and set the
260260
writer size to *size*. The caller is responsible to write *size*
261261
bytes using :c:func:`PyBytesWriter_GetData`.
262+
This function does not overallocate.
262263
263264
On error, set an exception and return ``NULL``.
264265
@@ -349,6 +350,8 @@ Low-level API
349350
350351
Resize the writer to *size* bytes. It can be used to enlarge or to
351352
shrink the writer.
353+
This function typically overallocates to achieve amortized performance when
354+
resizing multiple times.
352355
353356
Newly allocated bytes are left uninitialized.
354357
@@ -360,6 +363,8 @@ Low-level API
360363
.. c:function:: int PyBytesWriter_Grow(PyBytesWriter *writer, Py_ssize_t grow)
361364
362365
Resize the writer by adding *grow* bytes to the current writer size.
366+
This function typically overallocates to achieve amortized performance when
367+
resizing multiple times.
363368
364369
Newly allocated bytes are left uninitialized.
365370

0 commit comments

Comments
 (0)