mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
20
Objects/clinic/listobject.c.h
generated
20
Objects/clinic/listobject.c.h
generated
|
@ -50,22 +50,22 @@ exit:
|
|||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(list_clear__doc__,
|
||||
PyDoc_STRVAR(py_list_clear__doc__,
|
||||
"clear($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Remove all items from list.");
|
||||
|
||||
#define LIST_CLEAR_METHODDEF \
|
||||
{"clear", (PyCFunction)list_clear, METH_NOARGS, list_clear__doc__},
|
||||
#define PY_LIST_CLEAR_METHODDEF \
|
||||
{"clear", (PyCFunction)py_list_clear, METH_NOARGS, py_list_clear__doc__},
|
||||
|
||||
static PyObject *
|
||||
list_clear_impl(PyListObject *self);
|
||||
py_list_clear_impl(PyListObject *self);
|
||||
|
||||
static PyObject *
|
||||
list_clear(PyListObject *self, PyObject *Py_UNUSED(ignored))
|
||||
py_list_clear(PyListObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return list_clear_impl(self);
|
||||
return py_list_clear_impl(self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(list_copy__doc__,
|
||||
|
@ -95,14 +95,14 @@ PyDoc_STRVAR(list_append__doc__,
|
|||
#define LIST_APPEND_METHODDEF \
|
||||
{"append", (PyCFunction)list_append, METH_O, list_append__doc__},
|
||||
|
||||
PyDoc_STRVAR(list_extend__doc__,
|
||||
PyDoc_STRVAR(py_list_extend__doc__,
|
||||
"extend($self, iterable, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Extend list by appending elements from the iterable.");
|
||||
|
||||
#define LIST_EXTEND_METHODDEF \
|
||||
{"extend", (PyCFunction)list_extend, METH_O, list_extend__doc__},
|
||||
#define PY_LIST_EXTEND_METHODDEF \
|
||||
{"extend", (PyCFunction)py_list_extend, METH_O, py_list_extend__doc__},
|
||||
|
||||
PyDoc_STRVAR(list_pop__doc__,
|
||||
"pop($self, index=-1, /)\n"
|
||||
|
@ -384,4 +384,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
|
|||
{
|
||||
return list___reversed___impl(self);
|
||||
}
|
||||
/*[clinic end generated code: output=5dea9dd3bb219a7f input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=f2d7b63119464ff4 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue