Skip to content

Commit 05d0559

Browse files
gh-46236: Add PyUnicode_Resize() doc (#132628)
Co-authored-by: Stan Ulbrych <[email protected]>
1 parent d0660a9 commit 05d0559

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Doc/c-api/unicode.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,21 @@ APIs:
674674
.. versionadded:: 3.3
675675
676676
677+
.. c:function:: int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length);
678+
679+
Resize a Unicode object *\*unicode* to the new *length* in code points.
680+
681+
Try to resize the string in place (which is usually faster than allocating
682+
a new string and copying characters), or create a new string.
683+
684+
*\*unicode* is modified to point to the new (resized) object and ``0`` is
685+
returned on success. Otherwise, ``-1`` is returned and an exception is set,
686+
and *\*unicode* is left untouched.
687+
688+
The function doesn't check string content, the result may not be a
689+
string in canonical representation.
690+
691+
677692
.. c:function:: Py_ssize_t PyUnicode_Fill(PyObject *unicode, Py_ssize_t start, \
678693
Py_ssize_t length, Py_UCS4 fill_char)
679694

Doc/data/refcounts.dat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,6 +2794,10 @@ PyUnicode_CopyCharacters:PyObject*:from:0:
27942794
PyUnicode_CopyCharacters:Py_ssize_t:from_start::
27952795
PyUnicode_CopyCharacters:Py_ssize_t:how_many::
27962796

2797+
PyUnicode_Resize:int:::
2798+
PyUnicode_Resize:PyObject**:unicode:0:
2799+
PyUnicode_Resize:Py_ssize_t:length::
2800+
27972801
PyUnicode_Fill:Py_ssize_t:::
27982802
PyUnicode_Fill:PyObject*:unicode:0:
27992803
PyUnicode_Fill:Py_ssize_t:start::

0 commit comments

Comments
 (0)