if (rv == -1) { Py_DECREF(otherset); return NULL; } if (rv == DISCARD_NOTFOUND) { if (set_add_entry(so, entry) == -1) { Py_DECREF(otherset); return NULL; } } } Py_DECREF(otherset); Py_RETURN_NONE;} PyDoc_STRVAR(symmetric_difference_update_doc,"Update a set with the symmetric difference of itself and another."); static PyObject *set_symmetric_difference(PySetObject *so, PyObject *other){ PyObject *rv; PySetObject *otherset; otherset = (PySetObject *)make_new_set(so->ob_type, other); if (otherset == NULL) return NULL; rv = set_symmetric_difference_update(otherset, (PyObject *)so); if (rv == NULL) return NULL; Py_DECREF(rv); return (PyObject *)otherset;} PyDoc_STRVAR(symmetric_difference_doc,"Return the symmetric difference of two sets as a new set.\n\\n\(i.e. all elements that are in exactly one of the sets.)"); static PyObject *set_xor(PySetObject *so, PyObject *other){ if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } return set_symmetric_difference(so, other);} static PyObject *set_ixor(PySetObject *so, PyObject *other){ PyObject *result; if (!PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } result = set_symmetric_difference_update(so, other); if (result == NULL) return NULL; Py_DECREF(result); Py_INCREF(so); return (PyObject *)so;} static PyObject *set_issubset(PySetObject *so, PyObject *other){ setentry *entry; Py_ssize_t pos = 0; if (!PyAnySet_Check(other)) { PyObject *tmp, *result; tmp = make_new_set(&PySet_Type, other); if (tmp == NULL) return NULL; result = set_issubset(so, tmp); Py_DECREF(tmp); return result; } if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other)) Py_RETURN_FALSE; while (set_next(so, &pos, &entry)) { int rv = set_contains_entry((PySetObject *)other, entry); if (rv == -1) return NULL; if (!rv) Py_RETURN_FALSE; } Py_RETURN_TRUE;} PyDoc_STRVAR(issubset_doc, "Report whether another set contains this set."); static PyObject *set_issuperset(PySetObject *so, PyObject *other){ PyObject *tmp, *result; if (!PyAnySet_Check(other)) { tmp = make_new_set(&PySet_Type, other); if (tmp == NULL) return NULL; result = set_issuperset(so, tmp); Py_DECREF(tmp); return result; } return set_issubset((PySetObject *)other, (PyObject *)so);} PyDoc_STRVAR(issuperset_doc, "Report whether this set contains another set."); static PyObject *set_richcompare(PySetObject *v, PyObject *w, int op){ PyObject *r1, *r2; if(!PyAnySet_Check(w)) { if (op == Py_EQ) Py_RETURN_FALSE; if (op == Py_NE) Py_RETURN_TRUE; PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; } switch (op) { case Py_EQ: if (PySet_GET_SIZE(v) != PySet_GET_SIZE(w)) Py_RETURN_FALSE; if (v->hash != -1 && ((PySetObject *)w)->hash != -1 && v->hash != ((PySetObject *)w)->hash) Py_RETURN_FALSE; return set_issubset(v, w); case Py_NE: r1 = set_richcompare(v, w, Py_EQ); if (r1 == NULL) return NULL; r2 = PyBool_FromLong(PyObject_Not(r1)); Py_DECREF(r1); return r2; case Py_LE: return set_issubset(v, w); case Py_GE: return set_issuperset(v, w); case Py_LT: if (PySet_GET_SIZE(v) >= PySet_GET_SIZE(w)) Py_RETURN_FALSE; return set_issubset(v, w); case Py_GT: if (PySet_GET_SIZE(v) <= PySet_GET_SIZE(w)) Py_RETURN_FALSE; return set_issuperset(v, w); } Py_INCREF(Py_NotImplemented); return Py_NotImplemented;} static intset_nocmp(PyObject *self, PyObject *other){ PyErr_SetString(PyExc_TypeError, "cannot compare sets using cmp()"); return -1;} static PyObject *set_add(PySetObject *so, PyObject *key){ if (set_add_key(so, key) == -1) return NULL; 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 intset_contains(PySetObject *so, PyObject *key){ PyObject *tmpkey; int rv; rv = set_contains_key(so, key); if (rv == -1) { if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError)) return -1; PyErr_Clear(); tmpkey = make_new_set(&PyFrozenSet_Type, NULL); if (tmpkey == NULL) return -1; set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); rv = set_contains(so, tmpkey); set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); Py_DECREF(tmpkey); } return rv;} static PyObject *set_direct_contains(PySetObject *so, PyObject *key){ long result; result = set_contains(so, key); if (result == -1) return NULL; return PyBool_FromLong(result);} PyDoc_STRVAR(contains_doc, "x.__contains__(y) <==> y in x."); static PyObject *set_remove(PySetObject *so, PyObject *key){ PyObject *tmpkey, *result; int rv; rv = set_discard_key(so, key); if (rv == -1) { if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError)) return NULL; PyErr_Clear(); tmpkey = make_new_set(&PyFrozenSet_Type, NULL); if (tmpkey == NULL) return NULL; set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); result = set_remove(so, tmpkey); set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); Py_DECREF(tmpkey); return result; } else if (rv == DISCARD_NOTFOUND) { set_key_error(key); return NULL; } Py_RETURN_NONE;} PyDoc_STRVAR(remove_doc,"Remove an element from a set; it must be a member.\n\\n\If the element is not a member, raise a KeyError."); static PyObject *set_discard(PySetObject *so, PyObject *key){ PyObject *tmpkey, *result; int rv; rv = set_discard_key(so, key); if (rv == -1) { if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError)) return NULL; PyErr_Clear(); tmpkey = make_new_set(&PyFrozenSet_Type, NULL); if (tmpkey == NULL) return NULL; set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); result = set_discard(so, tmpkey); set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); Py_DECREF(tmpkey); return result; } Py_RETURN_NONE;} PyDoc_STRVAR(discard_doc,"Remove an element from a set if it is a member.\n\\n\If the element is not a member, do nothing."); static PyObject *set_reduce(PySetObject *so){ PyObject *keys=NULL, *args=NULL, *result=NULL, *dict=NULL; keys = PySequence_List((PyObject *)so); if (keys == NULL) goto done; args = PyTuple_Pack(1, keys); if (args == NULL) goto done; dict = PyObject_GetAttrString((PyObject *)so, "__dict__"); if (dict == NULL) { PyErr_Clear(); dict = Py_None; Py_INCREF(dict); } result = PyTuple_Pack(3, so->ob_type, args, dict);done: Py_XDECREF(args); Py_XDECREF(keys); Py_XDECREF(dict); return result;} PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); static intset_init(PySetObject *self, PyObject *args, PyObject *kwds){ PyObject *iterable = NULL; if (!PyAnySet_Check(self)) return -1; if (!PyArg_UnpackTuple(args, self->ob_type->tp_name, 0, 1, &iterable)) return -1; set_clear_internal(self); self->hash = -1; if (iterable == NULL) return 0; return set_update_internal(self, iterable);} static PySequenceMethods set_as_sequence = { set_len, /* sq_length */ 0, /* sq_concat */ 0, /* sq_repeat */ 0, /* sq_item */ 0, /* sq_slice */ 0, /* sq_ass_item */ 0, /* sq_ass_slice */ (objobjproc)set_contains, /* sq_contains */}; /* set object ********************************************************/ #ifdef Py_DEBUGstatic PyObject *test_c_api(PySetObject *so); PyDoc_STRVAR(test_c_api_doc, "Exercises C API. Returns True.\n\All is well if assertions don't fail.");#endif static PyMethodDef set_methods[] = { {"add", (PyCFunction)set_add, METH_O, add_doc}, {"clear", (PyCFunction)set_clear, METH_NOARGS, clear_doc}, {"__contains__",(PyCFunction)set_direct_contains, METH_O | METH_COEXIST, contains_doc}, {"copy", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, {"discard", (PyCFunction)set_discard, METH_O, discard_doc}, {"difference", (PyCFunction)set_difference, METH_O, difference_doc}, {"difference_update", (PyCFunction)set_difference_update, METH_O, difference_update_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, {"intersection_update",(PyCFunction)set_intersection_update, METH_O, intersection_update_doc}, {"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}, {"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},#ifdef Py_DEBUG {"test_c_api", (PyCFunction)test_c_api, METH_NOARGS, test_c_api_doc},#endif {"union", (PyCFunction)set_union, METH_O, union_doc}, {"update", (PyCFunction)set_update, METH_O, update_doc}, {NULL, NULL} /* sentinel */}; static PyNumberMethods set_as_number = { 0, /*nb_add*/ (binaryfunc)set_sub, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ 0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ (binaryfunc)set_and, /*nb_and*/ (binaryfunc)set_xor, /*nb_xor*/ (binaryfunc)set_or, /*nb_or*/ 0, /*nb_coerce*/ 0, /*nb_int*/ 0, /*nb_long*/ 0, /*nb_float*/ 0, /*nb_oct*/ 0, /*nb_hex*/ 0, /*nb_inplace_add*/ (binaryfunc)set_isub, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ 0, /*nb_inplace_divide*/ 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ (binaryfunc)set_iand, /*nb_inplace_and*/ (binaryfunc)set_ixor, /*nb_inplace_xor*/ (binaryfunc)set_ior, /*nb_inplace_or*/}; PyDoc_STRVAR(set_doc,"set(iterable) --> set object\n\\n\Build an unordered collection of unique elements."); PyTypeObject PySet_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "set", /* tp_name */ sizeof(PySetObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)set_dealloc, /* tp_dealloc */ (printfunc)set_tp_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ set_nocmp, /* tp_compare */ (reprfunc)set_repr, /* tp_repr */ &set_as_number, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ set_nohash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES | Py_TPFLAGS_BASETYPE, /* tp_flags */ set_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ (richcmpfunc)set_richcompare, /* tp_richcompare */ offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ 0, /* tp_iternext */ set_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ (initproc)set_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ set_new, /* tp_new */ PyObject_GC_Del, /* tp_free */}; /* frozenset object ********************************************************/ static PyMethodDef frozenset_methods[] = { {"__contains__",(PyCFunction)set_direct_contains, METH_O | METH_COEXIST, contains_doc}, {"copy", (PyCFunction)frozenset_copy, METH_NOARGS, copy_doc}, {"difference", (PyCFunction)set_difference, METH_O, difference_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, {"issubset", (PyCFunction)set_issubset, METH_O, issubset_doc}, {"issuperset", (PyCFunction)set_issuperset, METH_O, issuperset_doc}, {"__reduce__", (PyCFunction)set_reduce, METH_NOARGS, reduce_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, {"union", (PyCFunction)set_union, METH_O, union_doc}, {NULL, NULL} /* sentinel */}; static PyNumberMethods frozenset_as_number = { 0, /*nb_add*/ (binaryfunc)set_sub, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/Lines 1501–2000 of 2312. Previous lines Load more
if (rv == -1) { Py_DECREF(otherset); return NULL; } if (rv == DISCARD_NOTFOUND) { if (set_add_entry(so, entry) == -1) { Py_DECREF(otherset); return NULL; } } } Py_DECREF(otherset); Py_RETURN_NONE; } PyDoc_STRVAR(symmetric_difference_update_doc, "Update a set with the symmetric difference of itself and another."); static PyObject * set_symmetric_difference(PySetObject *so, PyObject *other) { PyObject *rv; PySetObject *otherset; otherset = (PySetObject *)make_new_set(so->ob_type, other); if (otherset == NULL) return NULL; rv = set_symmetric_difference_update(otherset, (PyObject *)so); if (rv == NULL) return NULL; Py_DECREF(rv); return (PyObject *)otherset; } PyDoc_STRVAR(symmetric_difference_doc, "Return the symmetric difference of two sets as a new set.\n\ \n\ (i.e. all elements that are in exactly one of the sets.)"); static PyObject * set_xor(PySetObject *so, PyObject *other) { if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } return set_symmetric_difference(so, other); } static PyObject * set_ixor(PySetObject *so, PyObject *other) { PyObject *result; if (!PyAnySet_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } result = set_symmetric_difference_update(so, other); if (result == NULL) return NULL; Py_DECREF(result); Py_INCREF(so); return (PyObject *)so; } static PyObject * set_issubset(PySetObject *so, PyObject *other) { setentry *entry; Py_ssize_t pos = 0; if (!PyAnySet_Check(other)) { PyObject *tmp, *result; tmp = make_new_set(&PySet_Type, other); if (tmp == NULL) return NULL; result = set_issubset(so, tmp); Py_DECREF(tmp); return result; } if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other)) Py_RETURN_FALSE; while (set_next(so, &pos, &entry)) { int rv = set_contains_entry((PySetObject *)other, entry); if (rv == -1) return NULL; if (!rv) Py_RETURN_FALSE; } Py_RETURN_TRUE; } PyDoc_STRVAR(issubset_doc, "Report whether another set contains this set."); static PyObject * set_issuperset(PySetObject *so, PyObject *other) { PyObject *tmp, *result; if (!PyAnySet_Check(other)) { tmp = make_new_set(&PySet_Type, other); if (tmp == NULL) return NULL; result = set_issuperset(so, tmp); Py_DECREF(tmp); return result; } return set_issubset((PySetObject *)other, (PyObject *)so); } PyDoc_STRVAR(issuperset_doc, "Report whether this set contains another set."); static PyObject * set_richcompare(PySetObject *v, PyObject *w, int op) { PyObject *r1, *r2; if(!PyAnySet_Check(w)) { if (op == Py_EQ) Py_RETURN_FALSE; if (op == Py_NE) Py_RETURN_TRUE; PyErr_SetString(PyExc_TypeError, "can only compare to a set"); return NULL; } switch (op) { case Py_EQ: if (PySet_GET_SIZE(v) != PySet_GET_SIZE(w)) Py_RETURN_FALSE; if (v->hash != -1 && ((PySetObject *)w)->hash != -1 && v->hash != ((PySetObject *)w)->hash) Py_RETURN_FALSE; return set_issubset(v, w); case Py_NE: r1 = set_richcompare(v, w, Py_EQ); if (r1 == NULL) return NULL; r2 = PyBool_FromLong(PyObject_Not(r1)); Py_DECREF(r1); return r2; case Py_LE: return set_issubset(v, w); case Py_GE: return set_issuperset(v, w); case Py_LT: if (PySet_GET_SIZE(v) >= PySet_GET_SIZE(w)) Py_RETURN_FALSE; return set_issubset(v, w); case Py_GT: if (PySet_GET_SIZE(v) <= PySet_GET_SIZE(w)) Py_RETURN_FALSE; return set_issuperset(v, w); } Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } static int set_nocmp(PyObject *self, PyObject *other) { PyErr_SetString(PyExc_TypeError, "cannot compare sets using cmp()"); return -1; } static PyObject * set_add(PySetObject *so, PyObject *key) { if (set_add_key(so, key) == -1) return NULL; 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 set_contains(PySetObject *so, PyObject *key) { PyObject *tmpkey; int rv; rv = set_contains_key(so, key); if (rv == -1) { if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError)) return -1; PyErr_Clear(); tmpkey = make_new_set(&PyFrozenSet_Type, NULL); if (tmpkey == NULL) return -1; set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); rv = set_contains(so, tmpkey); set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); Py_DECREF(tmpkey); } return rv; } static PyObject * set_direct_contains(PySetObject *so, PyObject *key) { long result; result = set_contains(so, key); if (result == -1) return NULL; return PyBool_FromLong(result); } PyDoc_STRVAR(contains_doc, "x.__contains__(y) <==> y in x."); static PyObject * set_remove(PySetObject *so, PyObject *key) { PyObject *tmpkey, *result; int rv; rv = set_discard_key(so, key); if (rv == -1) { if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError)) return NULL; PyErr_Clear(); tmpkey = make_new_set(&PyFrozenSet_Type, NULL); if (tmpkey == NULL) return NULL; set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); result = set_remove(so, tmpkey); set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); Py_DECREF(tmpkey); return result; } else if (rv == DISCARD_NOTFOUND) { set_key_error(key); return NULL; } Py_RETURN_NONE; } PyDoc_STRVAR(remove_doc, "Remove an element from a set; it must be a member.\n\ \n\ If the element is not a member, raise a KeyError."); static PyObject * set_discard(PySetObject *so, PyObject *key) { PyObject *tmpkey, *result; int rv; rv = set_discard_key(so, key); if (rv == -1) { if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError)) return NULL; PyErr_Clear(); tmpkey = make_new_set(&PyFrozenSet_Type, NULL); if (tmpkey == NULL) return NULL; set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); result = set_discard(so, tmpkey); set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); Py_DECREF(tmpkey); return result; } Py_RETURN_NONE; } PyDoc_STRVAR(discard_doc, "Remove an element from a set if it is a member.\n\ \n\ If the element is not a member, do nothing."); static PyObject * set_reduce(PySetObject *so) { PyObject *keys=NULL, *args=NULL, *result=NULL, *dict=NULL; keys = PySequence_List((PyObject *)so); if (keys == NULL) goto done; args = PyTuple_Pack(1, keys); if (args == NULL) goto done; dict = PyObject_GetAttrString((PyObject *)so, "__dict__"); if (dict == NULL) { PyErr_Clear(); dict = Py_None; Py_INCREF(dict); } result = PyTuple_Pack(3, so->ob_type, args, dict); done: Py_XDECREF(args); Py_XDECREF(keys); Py_XDECREF(dict); return result; } PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); static int set_init(PySetObject *self, PyObject *args, PyObject *kwds) { PyObject *iterable = NULL; if (!PyAnySet_Check(self)) return -1; if (!PyArg_UnpackTuple(args, self->ob_type->tp_name, 0, 1, &iterable)) return -1; set_clear_internal(self); self->hash = -1; if (iterable == NULL) return 0; return set_update_internal(self, iterable); } static PySequenceMethods set_as_sequence = { set_len, /* sq_length */ 0, /* sq_concat */ 0, /* sq_repeat */ 0, /* sq_item */ 0, /* sq_slice */ 0, /* sq_ass_item */ 0, /* sq_ass_slice */ (objobjproc)set_contains, /* sq_contains */ }; /* set object ********************************************************/ #ifdef Py_DEBUG static PyObject *test_c_api(PySetObject *so); PyDoc_STRVAR(test_c_api_doc, "Exercises C API. Returns True.\n\ All is well if assertions don't fail."); #endif static PyMethodDef set_methods[] = { {"add", (PyCFunction)set_add, METH_O, add_doc}, {"clear", (PyCFunction)set_clear, METH_NOARGS, clear_doc}, {"__contains__",(PyCFunction)set_direct_contains, METH_O | METH_COEXIST, contains_doc}, {"copy", (PyCFunction)set_copy, METH_NOARGS, copy_doc}, {"discard", (PyCFunction)set_discard, METH_O, discard_doc}, {"difference", (PyCFunction)set_difference, METH_O, difference_doc}, {"difference_update", (PyCFunction)set_difference_update, METH_O, difference_update_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, {"intersection_update",(PyCFunction)set_intersection_update, METH_O, intersection_update_doc}, {"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}, {"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}, #ifdef Py_DEBUG {"test_c_api", (PyCFunction)test_c_api, METH_NOARGS, test_c_api_doc}, #endif {"union", (PyCFunction)set_union, METH_O, union_doc}, {"update", (PyCFunction)set_update, METH_O, update_doc}, {NULL, NULL} /* sentinel */ }; static PyNumberMethods set_as_number = { 0, /*nb_add*/ (binaryfunc)set_sub, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ 0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ (binaryfunc)set_and, /*nb_and*/ (binaryfunc)set_xor, /*nb_xor*/ (binaryfunc)set_or, /*nb_or*/ 0, /*nb_coerce*/ 0, /*nb_int*/ 0, /*nb_long*/ 0, /*nb_float*/ 0, /*nb_oct*/ 0, /*nb_hex*/ 0, /*nb_inplace_add*/ (binaryfunc)set_isub, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ 0, /*nb_inplace_divide*/ 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ (binaryfunc)set_iand, /*nb_inplace_and*/ (binaryfunc)set_ixor, /*nb_inplace_xor*/ (binaryfunc)set_ior, /*nb_inplace_or*/ }; PyDoc_STRVAR(set_doc, "set(iterable) --> set object\n\ \n\ Build an unordered collection of unique elements."); PyTypeObject PySet_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "set", /* tp_name */ sizeof(PySetObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)set_dealloc, /* tp_dealloc */ (printfunc)set_tp_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ set_nocmp, /* tp_compare */ (reprfunc)set_repr, /* tp_repr */ &set_as_number, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ set_nohash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES | Py_TPFLAGS_BASETYPE, /* tp_flags */ set_doc, /* tp_doc */ (traverseproc)set_traverse, /* tp_traverse */ (inquiry)set_clear_internal, /* tp_clear */ (richcmpfunc)set_richcompare, /* tp_richcompare */ offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ 0, /* tp_iternext */ set_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ (initproc)set_init, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ set_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; /* frozenset object ********************************************************/ static PyMethodDef frozenset_methods[] = { {"__contains__",(PyCFunction)set_direct_contains, METH_O | METH_COEXIST, contains_doc}, {"copy", (PyCFunction)frozenset_copy, METH_NOARGS, copy_doc}, {"difference", (PyCFunction)set_difference, METH_O, difference_doc}, {"intersection",(PyCFunction)set_intersection, METH_O, intersection_doc}, {"issubset", (PyCFunction)set_issubset, METH_O, issubset_doc}, {"issuperset", (PyCFunction)set_issuperset, METH_O, issuperset_doc}, {"__reduce__", (PyCFunction)set_reduce, METH_NOARGS, reduce_doc}, {"symmetric_difference",(PyCFunction)set_symmetric_difference, METH_O, symmetric_difference_doc}, {"union", (PyCFunction)set_union, METH_O, union_doc}, {NULL, NULL} /* sentinel */ }; static PyNumberMethods frozenset_as_number = { 0, /*nb_add*/ (binaryfunc)set_sub, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/