mirror of
https://github.com/python/cpython.git
synced 2025-09-13 12:17:24 +00:00
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:
parent
29af7369db
commit
babb787047
8 changed files with 305 additions and 129 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue