Skip to content

gh-112087: Update list.{pop,clear,reverse,remove} to use CS #113764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions Objects/clinic/listobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ list_ass_item(PyObject *aa, Py_ssize_t i, PyObject *v)
}

/*[clinic input]
@critical_section
list.insert

index: Py_ssize_t
Expand All @@ -809,22 +810,23 @@ Insert object before index.

static PyObject *
list_insert_impl(PyListObject *self, Py_ssize_t index, PyObject *object)
/*[clinic end generated code: output=7f35e32f60c8cb78 input=858514cf894c7eab]*/
/*[clinic end generated code: output=7f35e32f60c8cb78 input=b1987ca998a4ae2d]*/
{
if (ins1(self, index, object) == 0)
Py_RETURN_NONE;
return NULL;
}

/*[clinic input]
@critical_section
list.clear as py_list_clear

Remove all items from list.
[clinic start generated code]*/

static PyObject *
py_list_clear_impl(PyListObject *self)
/*[clinic end generated code: output=83726743807e3518 input=378711e10f545c53]*/
/*[clinic end generated code: output=83726743807e3518 input=e285b7f09051a9ba]*/
{
list_clear(self);
Py_RETURN_NONE;
Expand Down Expand Up @@ -1062,6 +1064,7 @@ list_inplace_concat(PyObject *_self, PyObject *other)
}

/*[clinic input]
@critical_section
list.pop

index: Py_ssize_t = -1
Expand All @@ -1074,7 +1077,7 @@ Raises IndexError if list is empty or index is out of range.

static PyObject *
list_pop_impl(PyListObject *self, Py_ssize_t index)
/*[clinic end generated code: output=6bd69dcb3f17eca8 input=b83675976f329e6f]*/
/*[clinic end generated code: output=6bd69dcb3f17eca8 input=c269141068ae4b8f]*/
{
PyObject *v;
int status;
Expand Down Expand Up @@ -2593,14 +2596,15 @@ PyList_Sort(PyObject *v)
}

/*[clinic input]
@critical_section
list.reverse

Reverse *IN PLACE*.
[clinic start generated code]*/

static PyObject *
list_reverse_impl(PyListObject *self)
/*[clinic end generated code: output=482544fc451abea9 input=eefd4c3ae1bc9887]*/
/*[clinic end generated code: output=482544fc451abea9 input=04ac8e0c6a66e4d9]*/
{
if (Py_SIZE(self) > 1)
reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self));
Expand Down Expand Up @@ -2730,6 +2734,7 @@ list_count(PyListObject *self, PyObject *value)
}

/*[clinic input]
@critical_section
list.remove

value: object
Expand All @@ -2741,8 +2746,8 @@ Raises ValueError if the value is not present.
[clinic start generated code]*/

static PyObject *
list_remove(PyListObject *self, PyObject *value)
/*[clinic end generated code: output=f087e1951a5e30d1 input=2dc2ba5bb2fb1f82]*/
list_remove_impl(PyListObject *self, PyObject *value)
/*[clinic end generated code: output=b9b76a6633b18778 input=26c813dbb95aa93b]*/
{
Py_ssize_t i;

Expand Down