mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-114894: add array.array.clear() method (#114919)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: AN Long <aisk@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
5319c66550
commit
9d1a353230
7 changed files with 71 additions and 1 deletions
|
|
@ -868,6 +868,21 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
|
|||
return (PyObject *)np;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
array.array.clear
|
||||
|
||||
Remove all items from the array.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
array_array_clear_impl(arrayobject *self)
|
||||
/*[clinic end generated code: output=5efe0417062210a9 input=5dffa30e94e717a4]*/
|
||||
{
|
||||
if (array_resize(self, 0) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
array.array.__copy__
|
||||
|
|
@ -2342,6 +2357,7 @@ static PyMethodDef array_methods[] = {
|
|||
ARRAY_ARRAY_APPEND_METHODDEF
|
||||
ARRAY_ARRAY_BUFFER_INFO_METHODDEF
|
||||
ARRAY_ARRAY_BYTESWAP_METHODDEF
|
||||
ARRAY_ARRAY_CLEAR_METHODDEF
|
||||
ARRAY_ARRAY___COPY___METHODDEF
|
||||
ARRAY_ARRAY_COUNT_METHODDEF
|
||||
ARRAY_ARRAY___DEEPCOPY___METHODDEF
|
||||
|
|
|
|||
20
Modules/clinic/arraymodule.c.h
generated
20
Modules/clinic/arraymodule.c.h
generated
|
|
@ -5,6 +5,24 @@ preserve
|
|||
#include "pycore_abstract.h" // _PyNumber_Index()
|
||||
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
|
||||
|
||||
PyDoc_STRVAR(array_array_clear__doc__,
|
||||
"clear($self, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Remove all items from the array.");
|
||||
|
||||
#define ARRAY_ARRAY_CLEAR_METHODDEF \
|
||||
{"clear", (PyCFunction)array_array_clear, METH_NOARGS, array_array_clear__doc__},
|
||||
|
||||
static PyObject *
|
||||
array_array_clear_impl(arrayobject *self);
|
||||
|
||||
static PyObject *
|
||||
array_array_clear(arrayobject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
return array_array_clear_impl(self);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(array_array___copy____doc__,
|
||||
"__copy__($self, /)\n"
|
||||
"--\n"
|
||||
|
|
@ -667,4 +685,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
|
|||
|
||||
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
|
||||
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
|
||||
/*[clinic end generated code: output=3be987238a4bb431 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=52c55d9b1d026c1c input=a9049054013a1b77]*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue