mirror of https://github.com/python/cpython
gh-112069: Adapt set/frozenset methods to Argument Clinic (#115112)
This commit is contained in:
parent
17689e3c41
commit
ed1a8daf10
|
@ -0,0 +1 @@
|
||||||
|
Adapt :class:`set` and :class:`frozenset` methods to Argument Clinic.
|
|
@ -0,0 +1,414 @@
|
||||||
|
/*[clinic input]
|
||||||
|
preserve
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
|
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_pop__doc__,
|
||||||
|
"pop($self, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Remove and return an arbitrary set element.\n"
|
||||||
|
"\n"
|
||||||
|
"Raises KeyError if the set is empty.");
|
||||||
|
|
||||||
|
#define SET_POP_METHODDEF \
|
||||||
|
{"pop", (PyCFunction)set_pop, METH_NOARGS, set_pop__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_pop_impl(PySetObject *so);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_pop(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return set_pop_impl(so);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_update__doc__,
|
||||||
|
"update($self, /, *others)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Update the set, adding elements from all others.");
|
||||||
|
|
||||||
|
#define SET_UPDATE_METHODDEF \
|
||||||
|
{"update", _PyCFunction_CAST(set_update), METH_FASTCALL, set_update__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_update_impl(PySetObject *so, PyObject *args);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_update(PySetObject *so, PyObject *const *args, Py_ssize_t nargs)
|
||||||
|
{
|
||||||
|
PyObject *return_value = NULL;
|
||||||
|
PyObject *__clinic_args = NULL;
|
||||||
|
|
||||||
|
if (!_PyArg_CheckPositional("update", nargs, 0, PY_SSIZE_T_MAX)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
__clinic_args = PyTuple_New(nargs - 0);
|
||||||
|
if (!__clinic_args) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
|
||||||
|
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
|
||||||
|
}
|
||||||
|
return_value = set_update_impl(so, __clinic_args);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
Py_XDECREF(__clinic_args);
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_copy__doc__,
|
||||||
|
"copy($self, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return a shallow copy of a set.");
|
||||||
|
|
||||||
|
#define SET_COPY_METHODDEF \
|
||||||
|
{"copy", (PyCFunction)set_copy, METH_NOARGS, set_copy__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_copy_impl(PySetObject *so);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_copy(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return set_copy_impl(so);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(frozenset_copy__doc__,
|
||||||
|
"copy($self, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return a shallow copy of a set.");
|
||||||
|
|
||||||
|
#define FROZENSET_COPY_METHODDEF \
|
||||||
|
{"copy", (PyCFunction)frozenset_copy, METH_NOARGS, frozenset_copy__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
frozenset_copy_impl(PySetObject *so);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
frozenset_copy(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return frozenset_copy_impl(so);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_clear__doc__,
|
||||||
|
"clear($self, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Remove all elements from this set.");
|
||||||
|
|
||||||
|
#define SET_CLEAR_METHODDEF \
|
||||||
|
{"clear", (PyCFunction)set_clear, METH_NOARGS, set_clear__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_clear_impl(PySetObject *so);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_clear(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return set_clear_impl(so);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_union__doc__,
|
||||||
|
"union($self, /, *others)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return a new set with elements from the set and all others.");
|
||||||
|
|
||||||
|
#define SET_UNION_METHODDEF \
|
||||||
|
{"union", _PyCFunction_CAST(set_union), METH_FASTCALL, set_union__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_union_impl(PySetObject *so, PyObject *args);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_union(PySetObject *so, PyObject *const *args, Py_ssize_t nargs)
|
||||||
|
{
|
||||||
|
PyObject *return_value = NULL;
|
||||||
|
PyObject *__clinic_args = NULL;
|
||||||
|
|
||||||
|
if (!_PyArg_CheckPositional("union", nargs, 0, PY_SSIZE_T_MAX)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
__clinic_args = PyTuple_New(nargs - 0);
|
||||||
|
if (!__clinic_args) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
|
||||||
|
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
|
||||||
|
}
|
||||||
|
return_value = set_union_impl(so, __clinic_args);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
Py_XDECREF(__clinic_args);
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_intersection_multi__doc__,
|
||||||
|
"intersection($self, /, *others)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return a new set with elements common to the set and all others.");
|
||||||
|
|
||||||
|
#define SET_INTERSECTION_MULTI_METHODDEF \
|
||||||
|
{"intersection", _PyCFunction_CAST(set_intersection_multi), METH_FASTCALL, set_intersection_multi__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_intersection_multi_impl(PySetObject *so, PyObject *args);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_intersection_multi(PySetObject *so, PyObject *const *args, Py_ssize_t nargs)
|
||||||
|
{
|
||||||
|
PyObject *return_value = NULL;
|
||||||
|
PyObject *__clinic_args = NULL;
|
||||||
|
|
||||||
|
if (!_PyArg_CheckPositional("intersection", nargs, 0, PY_SSIZE_T_MAX)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
__clinic_args = PyTuple_New(nargs - 0);
|
||||||
|
if (!__clinic_args) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
|
||||||
|
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
|
||||||
|
}
|
||||||
|
return_value = set_intersection_multi_impl(so, __clinic_args);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
Py_XDECREF(__clinic_args);
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_intersection_update_multi__doc__,
|
||||||
|
"intersection_update($self, /, *others)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Update the set, keeping only elements found in it and all others.");
|
||||||
|
|
||||||
|
#define SET_INTERSECTION_UPDATE_MULTI_METHODDEF \
|
||||||
|
{"intersection_update", _PyCFunction_CAST(set_intersection_update_multi), METH_FASTCALL, set_intersection_update_multi__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_intersection_update_multi_impl(PySetObject *so, PyObject *args);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_intersection_update_multi(PySetObject *so, PyObject *const *args, Py_ssize_t nargs)
|
||||||
|
{
|
||||||
|
PyObject *return_value = NULL;
|
||||||
|
PyObject *__clinic_args = NULL;
|
||||||
|
|
||||||
|
if (!_PyArg_CheckPositional("intersection_update", nargs, 0, PY_SSIZE_T_MAX)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
__clinic_args = PyTuple_New(nargs - 0);
|
||||||
|
if (!__clinic_args) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
|
||||||
|
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
|
||||||
|
}
|
||||||
|
return_value = set_intersection_update_multi_impl(so, __clinic_args);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
Py_XDECREF(__clinic_args);
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_isdisjoint__doc__,
|
||||||
|
"isdisjoint($self, other, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return True if two sets have a null intersection.");
|
||||||
|
|
||||||
|
#define SET_ISDISJOINT_METHODDEF \
|
||||||
|
{"isdisjoint", (PyCFunction)set_isdisjoint, METH_O, set_isdisjoint__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_difference_update__doc__,
|
||||||
|
"difference_update($self, /, *others)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Update the set, removing elements found in others.");
|
||||||
|
|
||||||
|
#define SET_DIFFERENCE_UPDATE_METHODDEF \
|
||||||
|
{"difference_update", _PyCFunction_CAST(set_difference_update), METH_FASTCALL, set_difference_update__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_difference_update_impl(PySetObject *so, PyObject *args);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_difference_update(PySetObject *so, PyObject *const *args, Py_ssize_t nargs)
|
||||||
|
{
|
||||||
|
PyObject *return_value = NULL;
|
||||||
|
PyObject *__clinic_args = NULL;
|
||||||
|
|
||||||
|
if (!_PyArg_CheckPositional("difference_update", nargs, 0, PY_SSIZE_T_MAX)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
__clinic_args = PyTuple_New(nargs - 0);
|
||||||
|
if (!__clinic_args) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
|
||||||
|
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
|
||||||
|
}
|
||||||
|
return_value = set_difference_update_impl(so, __clinic_args);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
Py_XDECREF(__clinic_args);
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_difference_multi__doc__,
|
||||||
|
"difference($self, /, *others)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return a new set with elements in the set that are not in the others.");
|
||||||
|
|
||||||
|
#define SET_DIFFERENCE_MULTI_METHODDEF \
|
||||||
|
{"difference", _PyCFunction_CAST(set_difference_multi), METH_FASTCALL, set_difference_multi__doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_difference_multi_impl(PySetObject *so, PyObject *args);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set_difference_multi(PySetObject *so, PyObject *const *args, Py_ssize_t nargs)
|
||||||
|
{
|
||||||
|
PyObject *return_value = NULL;
|
||||||
|
PyObject *__clinic_args = NULL;
|
||||||
|
|
||||||
|
if (!_PyArg_CheckPositional("difference", nargs, 0, PY_SSIZE_T_MAX)) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
__clinic_args = PyTuple_New(nargs - 0);
|
||||||
|
if (!__clinic_args) {
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
|
||||||
|
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
|
||||||
|
}
|
||||||
|
return_value = set_difference_multi_impl(so, __clinic_args);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
Py_XDECREF(__clinic_args);
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_symmetric_difference_update__doc__,
|
||||||
|
"symmetric_difference_update($self, other, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Update the set, keeping only elements found in either set, but not in both.");
|
||||||
|
|
||||||
|
#define SET_SYMMETRIC_DIFFERENCE_UPDATE_METHODDEF \
|
||||||
|
{"symmetric_difference_update", (PyCFunction)set_symmetric_difference_update, METH_O, set_symmetric_difference_update__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_symmetric_difference__doc__,
|
||||||
|
"symmetric_difference($self, other, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return a new set with elements in either the set or other but not both.");
|
||||||
|
|
||||||
|
#define SET_SYMMETRIC_DIFFERENCE_METHODDEF \
|
||||||
|
{"symmetric_difference", (PyCFunction)set_symmetric_difference, METH_O, set_symmetric_difference__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_issubset__doc__,
|
||||||
|
"issubset($self, other, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Report whether another set contains this set.");
|
||||||
|
|
||||||
|
#define SET_ISSUBSET_METHODDEF \
|
||||||
|
{"issubset", (PyCFunction)set_issubset, METH_O, set_issubset__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_issuperset__doc__,
|
||||||
|
"issuperset($self, other, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Report whether this set contains another set.");
|
||||||
|
|
||||||
|
#define SET_ISSUPERSET_METHODDEF \
|
||||||
|
{"issuperset", (PyCFunction)set_issuperset, METH_O, set_issuperset__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_add__doc__,
|
||||||
|
"add($self, object, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Add an element to a set.\n"
|
||||||
|
"\n"
|
||||||
|
"This has no effect if the element is already present.");
|
||||||
|
|
||||||
|
#define SET_ADD_METHODDEF \
|
||||||
|
{"add", (PyCFunction)set_add, METH_O, set_add__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set___contains____doc__,
|
||||||
|
"__contains__($self, object, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"x.__contains__(y) <==> y in x.");
|
||||||
|
|
||||||
|
#define SET___CONTAINS___METHODDEF \
|
||||||
|
{"__contains__", (PyCFunction)set___contains__, METH_O|METH_COEXIST, set___contains____doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_remove__doc__,
|
||||||
|
"remove($self, object, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Remove an element from a set; it must be a member.\n"
|
||||||
|
"\n"
|
||||||
|
"If the element is not a member, raise a KeyError.");
|
||||||
|
|
||||||
|
#define SET_REMOVE_METHODDEF \
|
||||||
|
{"remove", (PyCFunction)set_remove, METH_O, set_remove__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set_discard__doc__,
|
||||||
|
"discard($self, object, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Remove an element from a set if it is a member.\n"
|
||||||
|
"\n"
|
||||||
|
"Unlike set.remove(), the discard() method does not raise\n"
|
||||||
|
"an exception when an element is missing from the set.");
|
||||||
|
|
||||||
|
#define SET_DISCARD_METHODDEF \
|
||||||
|
{"discard", (PyCFunction)set_discard, METH_O, set_discard__doc__},
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set___reduce____doc__,
|
||||||
|
"__reduce__($self, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"Return state information for pickling.");
|
||||||
|
|
||||||
|
#define SET___REDUCE___METHODDEF \
|
||||||
|
{"__reduce__", (PyCFunction)set___reduce__, METH_NOARGS, set___reduce____doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set___reduce___impl(PySetObject *so);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set___reduce__(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return set___reduce___impl(so);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(set___sizeof____doc__,
|
||||||
|
"__sizeof__($self, /)\n"
|
||||||
|
"--\n"
|
||||||
|
"\n"
|
||||||
|
"S.__sizeof__() -> size of S in memory, in bytes.");
|
||||||
|
|
||||||
|
#define SET___SIZEOF___METHODDEF \
|
||||||
|
{"__sizeof__", (PyCFunction)set___sizeof__, METH_NOARGS, set___sizeof____doc__},
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set___sizeof___impl(PySetObject *so);
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
set___sizeof__(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
|
{
|
||||||
|
return set___sizeof___impl(so);
|
||||||
|
}
|
||||||
|
/*[clinic end generated code: output=34a30591148da884 input=a9049054013a1b77]*/
|
|
@ -40,6 +40,19 @@
|
||||||
#include "pycore_pyerrors.h" // _PyErr_SetKeyError()
|
#include "pycore_pyerrors.h" // _PyErr_SetKeyError()
|
||||||
#include "pycore_setobject.h" // _PySet_NextEntry() definition
|
#include "pycore_setobject.h" // _PySet_NextEntry() definition
|
||||||
#include <stddef.h> // offsetof()
|
#include <stddef.h> // offsetof()
|
||||||
|
#include "clinic/setobject.c.h"
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
class set "PySetObject *" "&PySet_Type"
|
||||||
|
class frozenset "PySetObject *" "&PyFrozenSet_Type"
|
||||||
|
[clinic start generated code]*/
|
||||||
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=97ad1d3e9f117079]*/
|
||||||
|
|
||||||
|
/*[python input]
|
||||||
|
class setobject_converter(self_converter):
|
||||||
|
type = "PySetObject *"
|
||||||
|
[python start generated code]*/
|
||||||
|
/*[python end generated code: output=da39a3ee5e6b4b0d input=33a44506d4d57793]*/
|
||||||
|
|
||||||
/* Object used as dummy key to fill deleted entries */
|
/* Object used as dummy key to fill deleted entries */
|
||||||
static PyObject _dummy_struct;
|
static PyObject _dummy_struct;
|
||||||
|
@ -631,8 +644,18 @@ set_merge(PySetObject *so, PyObject *otherset)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.pop
|
||||||
|
so: setobject
|
||||||
|
|
||||||
|
Remove and return an arbitrary set element.
|
||||||
|
|
||||||
|
Raises KeyError if the set is empty.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_pop(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
set_pop_impl(PySetObject *so)
|
||||||
|
/*[clinic end generated code: output=4d65180f1271871b input=4a3f5552e660a260]*/
|
||||||
{
|
{
|
||||||
/* Make sure the search finger is in bounds */
|
/* Make sure the search finger is in bounds */
|
||||||
setentry *entry = so->table + (so->finger & so->mask);
|
setentry *entry = so->table + (so->finger & so->mask);
|
||||||
|
@ -656,9 +679,6 @@ set_pop(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.\n\
|
|
||||||
Raises KeyError if the set is empty.");
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
set_traverse(PySetObject *so, visitproc visit, void *arg)
|
set_traverse(PySetObject *so, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
|
@ -935,8 +955,18 @@ exit:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.update
|
||||||
|
so: setobject
|
||||||
|
*others as args: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Update the set, adding elements from all others.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_update(PySetObject *so, PyObject *args)
|
set_update_impl(PySetObject *so, PyObject *args)
|
||||||
|
/*[clinic end generated code: output=34f6371704974c8a input=eb47c4fbaeb3286e]*/
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
|
||||||
|
@ -948,12 +978,6 @@ set_update(PySetObject *so, PyObject *args)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(update_doc,
|
|
||||||
"update($self, /, *others)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Update the set, adding elements from all others.");
|
|
||||||
|
|
||||||
/* XXX Todo:
|
/* XXX Todo:
|
||||||
If aligned memory allocations become available, make the
|
If aligned memory allocations become available, make the
|
||||||
set object 64 byte aligned so that most of the fields
|
set object 64 byte aligned so that most of the fields
|
||||||
|
@ -1101,14 +1125,30 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.copy
|
||||||
|
so: setobject
|
||||||
|
|
||||||
|
Return a shallow copy of a set.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_copy(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
set_copy_impl(PySetObject *so)
|
||||||
|
/*[clinic end generated code: output=c9223a1e1cc6b041 input=2b80b288d47b8cf1]*/
|
||||||
{
|
{
|
||||||
return make_new_set_basetype(Py_TYPE(so), (PyObject *)so);
|
return make_new_set_basetype(Py_TYPE(so), (PyObject *)so);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
frozenset.copy
|
||||||
|
so: setobject
|
||||||
|
|
||||||
|
Return a shallow copy of a set.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
frozenset_copy(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
frozenset_copy_impl(PySetObject *so)
|
||||||
|
/*[clinic end generated code: output=b356263526af9e70 input=3dc65577d344eff7]*/
|
||||||
{
|
{
|
||||||
if (PyFrozenSet_CheckExact(so)) {
|
if (PyFrozenSet_CheckExact(so)) {
|
||||||
return Py_NewRef(so);
|
return Py_NewRef(so);
|
||||||
|
@ -1116,19 +1156,33 @@ frozenset_copy(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
return set_copy(so, NULL);
|
return set_copy(so, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(copy_doc, "Return a shallow copy of a set.");
|
/*[clinic input]
|
||||||
|
set.clear
|
||||||
|
so: setobject
|
||||||
|
|
||||||
|
Remove all elements from this set.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_clear(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
set_clear_impl(PySetObject *so)
|
||||||
|
/*[clinic end generated code: output=4e71d5a83904161a input=74ac19794da81a39]*/
|
||||||
{
|
{
|
||||||
set_clear_internal(so);
|
set_clear_internal(so);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(clear_doc, "Remove all elements from this set.");
|
/*[clinic input]
|
||||||
|
set.union
|
||||||
|
so: setobject
|
||||||
|
*others as args: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Return a new set with elements from the set and all others.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_union(PySetObject *so, PyObject *args)
|
set_union_impl(PySetObject *so, PyObject *args)
|
||||||
|
/*[clinic end generated code: output=2c83d05a446a1477 input=2e2024fa1e40ac84]*/
|
||||||
{
|
{
|
||||||
PySetObject *result;
|
PySetObject *result;
|
||||||
PyObject *other;
|
PyObject *other;
|
||||||
|
@ -1150,12 +1204,6 @@ set_union(PySetObject *so, PyObject *args)
|
||||||
return (PyObject *)result;
|
return (PyObject *)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(union_doc,
|
|
||||||
"union($self, /, *others)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Return a new set with elements from the set and all others.");
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_or(PySetObject *so, PyObject *other)
|
set_or(PySetObject *so, PyObject *other)
|
||||||
{
|
{
|
||||||
|
@ -1270,8 +1318,18 @@ set_intersection(PySetObject *so, PyObject *other)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.intersection as set_intersection_multi
|
||||||
|
so: setobject
|
||||||
|
*others as args: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Return a new set with elements common to the set and all others.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_intersection_multi(PySetObject *so, PyObject *args)
|
set_intersection_multi_impl(PySetObject *so, PyObject *args)
|
||||||
|
/*[clinic end generated code: output=2406ef3387adbe2f input=04108ea6d7f0532b]*/
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
|
||||||
|
@ -1291,12 +1349,6 @@ set_intersection_multi(PySetObject *so, PyObject *args)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(intersection_doc,
|
|
||||||
"intersection($self, /, *others)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Return a new set with elements common to the set and all others.");
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_intersection_update(PySetObject *so, PyObject *other)
|
set_intersection_update(PySetObject *so, PyObject *other)
|
||||||
{
|
{
|
||||||
|
@ -1310,12 +1362,22 @@ set_intersection_update(PySetObject *so, PyObject *other)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.intersection_update as set_intersection_update_multi
|
||||||
|
so: setobject
|
||||||
|
*others as args: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Update the set, keeping only elements found in it and all others.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_intersection_update_multi(PySetObject *so, PyObject *args)
|
set_intersection_update_multi_impl(PySetObject *so, PyObject *args)
|
||||||
|
/*[clinic end generated code: output=251c1f729063609d input=ff8f119f97458d16]*/
|
||||||
{
|
{
|
||||||
PyObject *tmp;
|
PyObject *tmp;
|
||||||
|
|
||||||
tmp = set_intersection_multi(so, args);
|
tmp = set_intersection_multi_impl(so, args);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
set_swap_bodies(so, (PySetObject *)tmp);
|
set_swap_bodies(so, (PySetObject *)tmp);
|
||||||
|
@ -1323,12 +1385,6 @@ set_intersection_update_multi(PySetObject *so, PyObject *args)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(intersection_update_doc,
|
|
||||||
"intersection_update($self, /, *others)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Update the set, keeping only elements found in it and all others.");
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_and(PySetObject *so, PyObject *other)
|
set_and(PySetObject *so, PyObject *other)
|
||||||
{
|
{
|
||||||
|
@ -1351,8 +1407,18 @@ set_iand(PySetObject *so, PyObject *other)
|
||||||
return Py_NewRef(so);
|
return Py_NewRef(so);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.isdisjoint
|
||||||
|
so: setobject
|
||||||
|
other: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Return True if two sets have a null intersection.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_isdisjoint(PySetObject *so, PyObject *other)
|
set_isdisjoint(PySetObject *so, PyObject *other)
|
||||||
|
/*[clinic end generated code: output=a92bbf9a2db6a3da input=c254ddec8a2326e3]*/
|
||||||
{
|
{
|
||||||
PyObject *key, *it, *tmp;
|
PyObject *key, *it, *tmp;
|
||||||
int rv;
|
int rv;
|
||||||
|
@ -1410,9 +1476,6 @@ set_isdisjoint(PySetObject *so, PyObject *other)
|
||||||
Py_RETURN_TRUE;
|
Py_RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(isdisjoint_doc,
|
|
||||||
"Return True if two sets have a null intersection.");
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
set_difference_update_internal(PySetObject *so, PyObject *other)
|
set_difference_update_internal(PySetObject *so, PyObject *other)
|
||||||
{
|
{
|
||||||
|
@ -1471,8 +1534,18 @@ set_difference_update_internal(PySetObject *so, PyObject *other)
|
||||||
return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4);
|
return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.difference_update
|
||||||
|
so: setobject
|
||||||
|
*others as args: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Update the set, removing elements found in others.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_difference_update(PySetObject *so, PyObject *args)
|
set_difference_update_impl(PySetObject *so, PyObject *args)
|
||||||
|
/*[clinic end generated code: output=28685b2fc63e41c4 input=e7abb43c9f2c5a73]*/
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
|
|
||||||
|
@ -1484,12 +1557,6 @@ set_difference_update(PySetObject *so, PyObject *args)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(difference_update_doc,
|
|
||||||
"difference_update($self, /, *others)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Update the set, removing elements found in others.");
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_copy_and_difference(PySetObject *so, PyObject *other)
|
set_copy_and_difference(PySetObject *so, PyObject *other)
|
||||||
{
|
{
|
||||||
|
@ -1580,8 +1647,18 @@ set_difference(PySetObject *so, PyObject *other)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.difference as set_difference_multi
|
||||||
|
so: setobject
|
||||||
|
*others as args: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Return a new set with elements in the set that are not in the others.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_difference_multi(PySetObject *so, PyObject *args)
|
set_difference_multi_impl(PySetObject *so, PyObject *args)
|
||||||
|
/*[clinic end generated code: output=3130c3bb3cac873d input=d8ae9bb6d518ab95]*/
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
PyObject *result, *other;
|
PyObject *result, *other;
|
||||||
|
@ -1604,11 +1681,6 @@ set_difference_multi(PySetObject *so, PyObject *args)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(difference_doc,
|
|
||||||
"difference($self, /, *others)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Return a new set with elements in the set that are not in the others.");
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_sub(PySetObject *so, PyObject *other)
|
set_sub(PySetObject *so, PyObject *other)
|
||||||
{
|
{
|
||||||
|
@ -1654,8 +1726,18 @@ set_symmetric_difference_update_dict(PySetObject *so, PyObject *other)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.symmetric_difference_update
|
||||||
|
so: setobject
|
||||||
|
other: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Update the set, keeping only elements found in either set, but not in both.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_symmetric_difference_update(PySetObject *so, PyObject *other)
|
set_symmetric_difference_update(PySetObject *so, PyObject *other)
|
||||||
|
/*[clinic end generated code: output=fbb049c0806028de input=a50acf0365e1f0a5]*/
|
||||||
{
|
{
|
||||||
PySetObject *otherset;
|
PySetObject *otherset;
|
||||||
PyObject *key;
|
PyObject *key;
|
||||||
|
@ -1708,14 +1790,18 @@ set_symmetric_difference_update(PySetObject *so, PyObject *other)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(symmetric_difference_update_doc,
|
/*[clinic input]
|
||||||
"symmetric_difference_update($self, other, /)\n\
|
set.symmetric_difference
|
||||||
--\n\
|
so: setobject
|
||||||
\n\
|
other: object
|
||||||
Update the set, keeping only elements found in either set, but not in both.");
|
/
|
||||||
|
|
||||||
|
Return a new set with elements in either the set or other but not both.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_symmetric_difference(PySetObject *so, PyObject *other)
|
set_symmetric_difference(PySetObject *so, PyObject *other)
|
||||||
|
/*[clinic end generated code: output=f95364211b88775a input=f18af370ad72ebac]*/
|
||||||
{
|
{
|
||||||
PyObject *rv;
|
PyObject *rv;
|
||||||
PySetObject *otherset;
|
PySetObject *otherset;
|
||||||
|
@ -1732,12 +1818,6 @@ set_symmetric_difference(PySetObject *so, PyObject *other)
|
||||||
return (PyObject *)otherset;
|
return (PyObject *)otherset;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(symmetric_difference_doc,
|
|
||||||
"symmetric_difference($self, other, /)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Return a new set with elements in either the set or other but not both.");
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_xor(PySetObject *so, PyObject *other)
|
set_xor(PySetObject *so, PyObject *other)
|
||||||
{
|
{
|
||||||
|
@ -1760,8 +1840,18 @@ set_ixor(PySetObject *so, PyObject *other)
|
||||||
return Py_NewRef(so);
|
return Py_NewRef(so);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.issubset
|
||||||
|
so: setobject
|
||||||
|
other: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Report whether another set contains this set.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_issubset(PySetObject *so, PyObject *other)
|
set_issubset(PySetObject *so, PyObject *other)
|
||||||
|
/*[clinic end generated code: output=78aef1f377aedef1 input=37fbc579b609db0c]*/
|
||||||
{
|
{
|
||||||
setentry *entry;
|
setentry *entry;
|
||||||
Py_ssize_t pos = 0;
|
Py_ssize_t pos = 0;
|
||||||
|
@ -1794,14 +1884,18 @@ set_issubset(PySetObject *so, PyObject *other)
|
||||||
Py_RETURN_TRUE;
|
Py_RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(issubset_doc,
|
/*[clinic input]
|
||||||
"issubset($self, other, /)\n\
|
set.issuperset
|
||||||
--\n\
|
so: setobject
|
||||||
\n\
|
other: object
|
||||||
Test whether every element in the set is in other.");
|
/
|
||||||
|
|
||||||
|
Report whether this set contains another set.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_issuperset(PySetObject *so, PyObject *other)
|
set_issuperset(PySetObject *so, PyObject *other)
|
||||||
|
/*[clinic end generated code: output=7d2b71dd714a7ec7 input=fd5dab052f2e9bb3]*/
|
||||||
{
|
{
|
||||||
if (PyAnySet_Check(other)) {
|
if (PyAnySet_Check(other)) {
|
||||||
return set_issubset((PySetObject *)other, (PyObject *)so);
|
return set_issubset((PySetObject *)other, (PyObject *)so);
|
||||||
|
@ -1830,12 +1924,6 @@ set_issuperset(PySetObject *so, PyObject *other)
|
||||||
Py_RETURN_TRUE;
|
Py_RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(issuperset_doc,
|
|
||||||
"issuperset($self, other, /)\n\
|
|
||||||
--\n\
|
|
||||||
\n\
|
|
||||||
Test whether every element in other is in the set.");
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_richcompare(PySetObject *v, PyObject *w, int op)
|
set_richcompare(PySetObject *v, PyObject *w, int op)
|
||||||
{
|
{
|
||||||
|
@ -1879,19 +1967,26 @@ set_richcompare(PySetObject *v, PyObject *w, int op)
|
||||||
Py_RETURN_NOTIMPLEMENTED;
|
Py_RETURN_NOTIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.add
|
||||||
|
so: setobject
|
||||||
|
object as key: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Add an element to a set.
|
||||||
|
|
||||||
|
This has no effect if the element is already present.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_add(PySetObject *so, PyObject *key)
|
set_add(PySetObject *so, PyObject *key)
|
||||||
|
/*[clinic end generated code: output=cd9c2d5c2069c2ba input=96f1efe029e47972]*/
|
||||||
{
|
{
|
||||||
if (set_add_key(so, key))
|
if (set_add_key(so, key))
|
||||||
return NULL;
|
return NULL;
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(add_doc,
|
|
||||||
"Add an element to a set.\n\
|
|
||||||
\n\
|
|
||||||
This has no effect if the element is already present.");
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
set_contains(PySetObject *so, PyObject *key)
|
set_contains(PySetObject *so, PyObject *key)
|
||||||
{
|
{
|
||||||
|
@ -1912,8 +2007,19 @@ set_contains(PySetObject *so, PyObject *key)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
@coexist
|
||||||
|
set.__contains__
|
||||||
|
so: setobject
|
||||||
|
object as key: object
|
||||||
|
/
|
||||||
|
|
||||||
|
x.__contains__(y) <==> y in x.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_direct_contains(PySetObject *so, PyObject *key)
|
set___contains__(PySetObject *so, PyObject *key)
|
||||||
|
/*[clinic end generated code: output=b5948bc5c590d3ca input=cf4c72db704e4cf0]*/
|
||||||
{
|
{
|
||||||
long result;
|
long result;
|
||||||
|
|
||||||
|
@ -1923,10 +2029,20 @@ set_direct_contains(PySetObject *so, PyObject *key)
|
||||||
return PyBool_FromLong(result);
|
return PyBool_FromLong(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(contains_doc, "x.__contains__(y) <==> y in x.");
|
/*[clinic input]
|
||||||
|
set.remove
|
||||||
|
so: setobject
|
||||||
|
object as key: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Remove an element from a set; it must be a member.
|
||||||
|
|
||||||
|
If the element is not a member, raise a KeyError.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_remove(PySetObject *so, PyObject *key)
|
set_remove(PySetObject *so, PyObject *key)
|
||||||
|
/*[clinic end generated code: output=08ae496d0cd2b8c1 input=10132515dfe8ebd7]*/
|
||||||
{
|
{
|
||||||
PyObject *tmpkey;
|
PyObject *tmpkey;
|
||||||
int rv;
|
int rv;
|
||||||
|
@ -1952,13 +2068,21 @@ set_remove(PySetObject *so, PyObject *key)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(remove_doc,
|
/*[clinic input]
|
||||||
"Remove an element from a set; it must be a member.\n\
|
set.discard
|
||||||
\n\
|
so: setobject
|
||||||
If the element is not a member, raise a KeyError.");
|
object as key: object
|
||||||
|
/
|
||||||
|
|
||||||
|
Remove an element from a set if it is a member.
|
||||||
|
|
||||||
|
Unlike set.remove(), the discard() method does not raise
|
||||||
|
an exception when an element is missing from the set.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_discard(PySetObject *so, PyObject *key)
|
set_discard(PySetObject *so, PyObject *key)
|
||||||
|
/*[clinic end generated code: output=9181b60d7bb7d480 input=82a689eba94d5ad9]*/
|
||||||
{
|
{
|
||||||
PyObject *tmpkey;
|
PyObject *tmpkey;
|
||||||
int rv;
|
int rv;
|
||||||
|
@ -1979,14 +2103,16 @@ set_discard(PySetObject *so, PyObject *key)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(discard_doc,
|
/*[clinic input]
|
||||||
"Remove an element from a set if it is a member.\n\
|
set.__reduce__
|
||||||
\n\
|
so: setobject
|
||||||
Unlike set.remove(), the discard() method does not raise\n\
|
|
||||||
an exception when an element is missing from the set.");
|
Return state information for pickling.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_reduce(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
set___reduce___impl(PySetObject *so)
|
||||||
|
/*[clinic end generated code: output=9af7d0e029df87ee input=531375e87a24a449]*/
|
||||||
{
|
{
|
||||||
PyObject *keys=NULL, *args=NULL, *result=NULL, *state=NULL;
|
PyObject *keys=NULL, *args=NULL, *result=NULL, *state=NULL;
|
||||||
|
|
||||||
|
@ -2007,8 +2133,16 @@ done:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[clinic input]
|
||||||
|
set.__sizeof__
|
||||||
|
so: setobject
|
||||||
|
|
||||||
|
S.__sizeof__() -> size of S in memory, in bytes.
|
||||||
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_sizeof(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
set___sizeof___impl(PySetObject *so)
|
||||||
|
/*[clinic end generated code: output=4bfa3df7bd38ed88 input=0f214fc2225319fc]*/
|
||||||
{
|
{
|
||||||
size_t res = _PyObject_SIZE(Py_TYPE(so));
|
size_t res = _PyObject_SIZE(Py_TYPE(so));
|
||||||
if (so->table != so->smalltable) {
|
if (so->table != so->smalltable) {
|
||||||
|
@ -2017,7 +2151,6 @@ set_sizeof(PySetObject *so, PyObject *Py_UNUSED(ignored))
|
||||||
return PyLong_FromSize_t(res);
|
return PyLong_FromSize_t(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(sizeof_doc, "S.__sizeof__() -> size of S in memory, in bytes");
|
|
||||||
static int
|
static int
|
||||||
set_init(PySetObject *self, PyObject *args, PyObject *kwds)
|
set_init(PySetObject *self, PyObject *args, PyObject *kwds)
|
||||||
{
|
{
|
||||||
|
@ -2071,46 +2204,26 @@ static PySequenceMethods set_as_sequence = {
|
||||||
/* set object ********************************************************/
|
/* set object ********************************************************/
|
||||||
|
|
||||||
static PyMethodDef set_methods[] = {
|
static PyMethodDef set_methods[] = {
|
||||||
{"add", (PyCFunction)set_add, METH_O,
|
SET_ADD_METHODDEF
|
||||||
add_doc},
|
SET_CLEAR_METHODDEF
|
||||||
{"clear", (PyCFunction)set_clear, METH_NOARGS,
|
SET___CONTAINS___METHODDEF
|
||||||
clear_doc},
|
SET_COPY_METHODDEF
|
||||||
{"__contains__",(PyCFunction)set_direct_contains, METH_O | METH_COEXIST,
|
SET_DISCARD_METHODDEF
|
||||||
contains_doc},
|
SET_DIFFERENCE_MULTI_METHODDEF
|
||||||
{"copy", (PyCFunction)set_copy, METH_NOARGS,
|
SET_DIFFERENCE_UPDATE_METHODDEF
|
||||||
copy_doc},
|
SET_INTERSECTION_MULTI_METHODDEF
|
||||||
{"discard", (PyCFunction)set_discard, METH_O,
|
SET_INTERSECTION_UPDATE_MULTI_METHODDEF
|
||||||
discard_doc},
|
SET_ISDISJOINT_METHODDEF
|
||||||
{"difference", (PyCFunction)set_difference_multi, METH_VARARGS,
|
SET_ISSUBSET_METHODDEF
|
||||||
difference_doc},
|
SET_ISSUPERSET_METHODDEF
|
||||||
{"difference_update", (PyCFunction)set_difference_update, METH_VARARGS,
|
SET_POP_METHODDEF
|
||||||
difference_update_doc},
|
SET___REDUCE___METHODDEF
|
||||||
{"intersection",(PyCFunction)set_intersection_multi, METH_VARARGS,
|
SET_REMOVE_METHODDEF
|
||||||
intersection_doc},
|
SET___SIZEOF___METHODDEF
|
||||||
{"intersection_update",(PyCFunction)set_intersection_update_multi, METH_VARARGS,
|
SET_SYMMETRIC_DIFFERENCE_METHODDEF
|
||||||
intersection_update_doc},
|
SET_SYMMETRIC_DIFFERENCE_UPDATE_METHODDEF
|
||||||
{"isdisjoint", (PyCFunction)set_isdisjoint, METH_O,
|
SET_UNION_METHODDEF
|
||||||
isdisjoint_doc},
|
SET_UPDATE_METHODDEF
|
||||||
{"issubset", (PyCFunction)set_issubset, METH_O,
|
|
||||||
issubset_doc},
|
|
||||||
{"issuperset", (PyCFunction)set_issuperset, METH_O,
|
|
||||||
issuperset_doc},
|
|
||||||
{"pop", (PyCFunction)set_pop, METH_NOARGS,
|
|
||||||
pop_doc},
|
|
||||||
{"__reduce__", (PyCFunction)set_reduce, METH_NOARGS,
|
|
||||||
reduce_doc},
|
|
||||||
{"remove", (PyCFunction)set_remove, METH_O,
|
|
||||||
remove_doc},
|
|
||||||
{"__sizeof__", (PyCFunction)set_sizeof, METH_NOARGS,
|
|
||||||
sizeof_doc},
|
|
||||||
{"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O,
|
|
||||||
symmetric_difference_doc},
|
|
||||||
{"symmetric_difference_update",(PyCFunction)set_symmetric_difference_update, METH_O,
|
|
||||||
symmetric_difference_update_doc},
|
|
||||||
{"union", (PyCFunction)set_union, METH_VARARGS,
|
|
||||||
union_doc},
|
|
||||||
{"update", (PyCFunction)set_update, METH_VARARGS,
|
|
||||||
update_doc},
|
|
||||||
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
@ -2203,28 +2316,17 @@ PyTypeObject PySet_Type = {
|
||||||
|
|
||||||
|
|
||||||
static PyMethodDef frozenset_methods[] = {
|
static PyMethodDef frozenset_methods[] = {
|
||||||
{"__contains__",(PyCFunction)set_direct_contains, METH_O | METH_COEXIST,
|
SET___CONTAINS___METHODDEF
|
||||||
contains_doc},
|
FROZENSET_COPY_METHODDEF
|
||||||
{"copy", (PyCFunction)frozenset_copy, METH_NOARGS,
|
SET_DIFFERENCE_MULTI_METHODDEF
|
||||||
copy_doc},
|
SET_INTERSECTION_MULTI_METHODDEF
|
||||||
{"difference", (PyCFunction)set_difference_multi, METH_VARARGS,
|
SET_ISDISJOINT_METHODDEF
|
||||||
difference_doc},
|
SET_ISSUBSET_METHODDEF
|
||||||
{"intersection", (PyCFunction)set_intersection_multi, METH_VARARGS,
|
SET_ISSUPERSET_METHODDEF
|
||||||
intersection_doc},
|
SET___REDUCE___METHODDEF
|
||||||
{"isdisjoint", (PyCFunction)set_isdisjoint, METH_O,
|
SET___SIZEOF___METHODDEF
|
||||||
isdisjoint_doc},
|
SET_SYMMETRIC_DIFFERENCE_METHODDEF
|
||||||
{"issubset", (PyCFunction)set_issubset, METH_O,
|
SET_UNION_METHODDEF
|
||||||
issubset_doc},
|
|
||||||
{"issuperset", (PyCFunction)set_issuperset, METH_O,
|
|
||||||
issuperset_doc},
|
|
||||||
{"__reduce__", (PyCFunction)set_reduce, METH_NOARGS,
|
|
||||||
reduce_doc},
|
|
||||||
{"__sizeof__", (PyCFunction)set_sizeof, METH_NOARGS,
|
|
||||||
sizeof_doc},
|
|
||||||
{"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O,
|
|
||||||
symmetric_difference_doc},
|
|
||||||
{"union", (PyCFunction)set_union, METH_VARARGS,
|
|
||||||
union_doc},
|
|
||||||
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue