gh-111138: Add PyList_Extend() and PyList_Clear() functions (#111862)

* Split list_extend() into two sub-functions: list_extend_fast() and
  list_extend_iter().
* list_inplace_concat() no longer has to call Py_DECREF() on the
  list_extend() result, since list_extend() now returns an int.
This commit is contained in:
Victor Stinner 2023-11-13 17:14:56 +01:00 committed by GitHub
parent 29af7369db
commit babb787047
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 305 additions and 129 deletions

View file

@ -128,6 +128,30 @@ List Objects
list is not supported.
.. c:function:: int PyList_Extend(PyObject *list, PyObject *iterable)
Extend *list* with the contents of *iterable*. This is the same as
``PyList_SetSlice(list, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, iterable)``
and analogous to ``list.extend(iterable)`` or ``list += iterable``.
Raise an exception and return ``-1`` if *list* is not a :class:`list`
object. Return 0 on success.
.. versionadded:: 3.13
.. c:function:: int PyList_Clear(PyObject *list)
Remove all items from *list*. This is the same as
``PyList_SetSlice(list, 0, PY_SSIZE_T_MAX, NULL)`` and analogous to
``list.clear()`` or ``del list[:]``.
Raise an exception and return ``-1`` if *list* is not a :class:`list`
object. Return 0 on success.
.. versionadded:: 3.13
.. c:function:: int PyList_Sort(PyObject *list)
Sort the items of *list* in place. Return ``0`` on success, ``-1`` on