summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-11-13 16:14:56 (GMT)
committerGitHub <noreply@github.com>2023-11-13 16:14:56 (GMT)
commitbabb787047e0f7807c8238d3b1a3128dac30bd5c (patch)
tree868cd78ee07ef9c20a5af32db79f979c543b8f0e /Modules
parent29af7369dbbbba8cefafb196e977bce8189a527d (diff)
downloadcpython-babb787047e0f7807c8238d3b1a3128dac30bd5c.zip
cpython-babb787047e0f7807c8238d3b1a3128dac30bd5c.tar.gz
cpython-babb787047e0f7807c8238d3b1a3128dac30bd5c.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapi/list.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/_testcapi/list.c b/Modules/_testcapi/list.c
index 6ba0e7a..10e1869 100644
--- a/Modules/_testcapi/list.c
+++ b/Modules/_testcapi/list.c
@@ -162,6 +162,25 @@ list_astuple(PyObject* Py_UNUSED(module), PyObject *obj)
}
+static PyObject *
+list_clear(PyObject* Py_UNUSED(module), PyObject *obj)
+{
+ NULLABLE(obj);
+ RETURN_INT(PyList_Clear(obj));
+}
+
+
+static PyObject *
+list_extend(PyObject* Py_UNUSED(module), PyObject *args)
+{
+ PyObject *obj, *arg;
+ if (!PyArg_ParseTuple(args, "OO", &obj, &arg)) {
+ return NULL;
+ }
+ NULLABLE(obj);
+ NULLABLE(arg);
+ RETURN_INT(PyList_Extend(obj, arg));
+}
static PyMethodDef test_methods[] = {
@@ -181,6 +200,8 @@ static PyMethodDef test_methods[] = {
{"list_sort", list_sort, METH_O},
{"list_reverse", list_reverse, METH_O},
{"list_astuple", list_astuple, METH_O},
+ {"list_clear", list_clear, METH_O},
+ {"list_extend", list_extend, METH_VARARGS},
{NULL},
};