mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #10516: adding list.clear() and list.copy() methods
This commit is contained in:
parent
3108f98319
commit
cbbaa96036
6 changed files with 81 additions and 2 deletions
|
@ -746,6 +746,19 @@ listinsert(PyListObject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
listclear(PyListObject *self)
|
||||
{
|
||||
list_clear(self);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
listcopy(PyListObject *self)
|
||||
{
|
||||
return list_slice(self, 0, Py_SIZE(self));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
listappend(PyListObject *self, PyObject *v)
|
||||
{
|
||||
|
@ -2322,6 +2335,10 @@ PyDoc_STRVAR(reversed_doc,
|
|||
"L.__reversed__() -- return a reverse iterator over the list");
|
||||
PyDoc_STRVAR(sizeof_doc,
|
||||
"L.__sizeof__() -- size of L in memory, in bytes");
|
||||
PyDoc_STRVAR(clear_doc,
|
||||
"L.clear() -> None -- remove all items from L");
|
||||
PyDoc_STRVAR(copy_doc,
|
||||
"L.copy() -> list -- a shallow copy of L");
|
||||
PyDoc_STRVAR(append_doc,
|
||||
"L.append(object) -- append object to end");
|
||||
PyDoc_STRVAR(extend_doc,
|
||||
|
@ -2350,9 +2367,11 @@ static PyMethodDef list_methods[] = {
|
|||
{"__getitem__", (PyCFunction)list_subscript, METH_O|METH_COEXIST, getitem_doc},
|
||||
{"__reversed__",(PyCFunction)list_reversed, METH_NOARGS, reversed_doc},
|
||||
{"__sizeof__", (PyCFunction)list_sizeof, METH_NOARGS, sizeof_doc},
|
||||
{"clear", (PyCFunction)listclear, METH_NOARGS, clear_doc},
|
||||
{"copy", (PyCFunction)listcopy, METH_NOARGS, copy_doc},
|
||||
{"append", (PyCFunction)listappend, METH_O, append_doc},
|
||||
{"insert", (PyCFunction)listinsert, METH_VARARGS, insert_doc},
|
||||
{"extend", (PyCFunction)listextend, METH_O, extend_doc},
|
||||
{"extend", (PyCFunction)listextend, METH_O, extend_doc},
|
||||
{"pop", (PyCFunction)listpop, METH_VARARGS, pop_doc},
|
||||
{"remove", (PyCFunction)listremove, METH_O, remove_doc},
|
||||
{"index", (PyCFunction)listindex, METH_VARARGS, index_doc},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue