@@ -746,6 +746,19 @@ listinsert(PyListObject *self, PyObject *args)
746746 return NULL ;
747747}
748748
749+ static PyObject *
750+ listclear (PyListObject * self )
751+ {
752+ list_clear (self );
753+ Py_RETURN_NONE ;
754+ }
755+
756+ static PyObject *
757+ listcopy (PyListObject * self )
758+ {
759+ return list_slice (self , 0 , Py_SIZE (self ));
760+ }
761+
749762static PyObject *
750763listappend (PyListObject * self , PyObject * v )
751764{
@@ -2322,6 +2335,10 @@ PyDoc_STRVAR(reversed_doc,
23222335"L.__reversed__() -- return a reverse iterator over the list" );
23232336PyDoc_STRVAR (sizeof_doc ,
23242337"L.__sizeof__() -- size of L in memory, in bytes" );
2338+ PyDoc_STRVAR (clear_doc ,
2339+ "L.clear() -> None -- remove all items from L" );
2340+ PyDoc_STRVAR (copy_doc ,
2341+ "L.copy() -> list -- a shallow copy of L" );
23252342PyDoc_STRVAR (append_doc ,
23262343"L.append(object) -- append object to end" );
23272344PyDoc_STRVAR (extend_doc ,
@@ -2350,9 +2367,11 @@ static PyMethodDef list_methods[] = {
23502367 {"__getitem__" , (PyCFunction )list_subscript , METH_O |METH_COEXIST , getitem_doc },
23512368 {"__reversed__" ,(PyCFunction )list_reversed , METH_NOARGS , reversed_doc },
23522369 {"__sizeof__" , (PyCFunction )list_sizeof , METH_NOARGS , sizeof_doc },
2370+ {"clear" , (PyCFunction )listclear , METH_NOARGS , clear_doc },
2371+ {"copy" , (PyCFunction )listcopy , METH_NOARGS , copy_doc },
23532372 {"append" , (PyCFunction )listappend , METH_O , append_doc },
23542373 {"insert" , (PyCFunction )listinsert , METH_VARARGS , insert_doc },
2355- {"extend" , (PyCFunction )listextend , METH_O , extend_doc },
2374+ {"extend" , (PyCFunction )listextend , METH_O , extend_doc },
23562375 {"pop" , (PyCFunction )listpop , METH_VARARGS , pop_doc },
23572376 {"remove" , (PyCFunction )listremove , METH_O , remove_doc },
23582377 {"index" , (PyCFunction )listindex , METH_VARARGS , index_doc },
0 commit comments