Skip to content

Commit 378072e

Browse files
101277: Add filterfalse type to module state
1 parent 4784128 commit 378072e

File tree

2 files changed

+31
-49
lines changed

2 files changed

+31
-49
lines changed

Modules/clinic/itertoolsmodule.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/itertoolsmodule.c

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ typedef struct {
1818
PyTypeObject *cwr_type;
1919
PyTypeObject *cycle_type;
2020
PyTypeObject *dropwhile_type;
21+
PyTypeObject *filterfalse_type;
2122
PyTypeObject *groupby_type;
2223
PyTypeObject *_grouper_type;
2324
PyTypeObject *permutations_type;
@@ -69,16 +70,15 @@ class itertools.combinations_with_replacement "cwr_object *" "clinic_state()->cw
6970
class itertools.permutations "permutationsobject *" "clinic_state()->permutations_type"
7071
class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type"
7172
class itertools.compress "compressobject *" "clinic_state()->compress_type"
72-
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
73+
class itertools.filterfalse "filterfalseobject *" "clinic_state()->filterfalse_type"
7374
class itertools.count "countobject *" "&count_type"
7475
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
7576
[clinic start generated code]*/
76-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=18f0df1fc6fbed08]*/
77+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=041cf92c608e0a3b]*/
7778

7879
static PyTypeObject teedataobject_type;
7980
static PyTypeObject tee_type;
8081
static PyTypeObject batched_type;
81-
static PyTypeObject filterfalse_type;
8282
static PyTypeObject count_type;
8383
static PyTypeObject pairwise_type;
8484

@@ -3978,15 +3978,18 @@ itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq)
39783978
static void
39793979
filterfalse_dealloc(filterfalseobject *lz)
39803980
{
3981+
PyTypeObject *tp = Py_TYPE(lz);
39813982
PyObject_GC_UnTrack(lz);
39823983
Py_XDECREF(lz->func);
39833984
Py_XDECREF(lz->it);
3984-
Py_TYPE(lz)->tp_free(lz);
3985+
tp->tp_free(lz);
3986+
Py_DECREF(tp);
39853987
}
39863988

39873989
static int
39883990
filterfalse_traverse(filterfalseobject *lz, visitproc visit, void *arg)
39893991
{
3992+
Py_VISIT(Py_TYPE(lz));
39903993
Py_VISIT(lz->it);
39913994
Py_VISIT(lz->func);
39923995
return 0;
@@ -4038,48 +4041,25 @@ static PyMethodDef filterfalse_methods[] = {
40384041
{NULL, NULL} /* sentinel */
40394042
};
40404043

4041-
static PyTypeObject filterfalse_type = {
4042-
PyVarObject_HEAD_INIT(NULL, 0)
4043-
"itertools.filterfalse", /* tp_name */
4044-
sizeof(filterfalseobject), /* tp_basicsize */
4045-
0, /* tp_itemsize */
4046-
/* methods */
4047-
(destructor)filterfalse_dealloc, /* tp_dealloc */
4048-
0, /* tp_vectorcall_offset */
4049-
0, /* tp_getattr */
4050-
0, /* tp_setattr */
4051-
0, /* tp_as_async */
4052-
0, /* tp_repr */
4053-
0, /* tp_as_number */
4054-
0, /* tp_as_sequence */
4055-
0, /* tp_as_mapping */
4056-
0, /* tp_hash */
4057-
0, /* tp_call */
4058-
0, /* tp_str */
4059-
PyObject_GenericGetAttr, /* tp_getattro */
4060-
0, /* tp_setattro */
4061-
0, /* tp_as_buffer */
4062-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
4063-
Py_TPFLAGS_BASETYPE, /* tp_flags */
4064-
itertools_filterfalse__doc__, /* tp_doc */
4065-
(traverseproc)filterfalse_traverse, /* tp_traverse */
4066-
0, /* tp_clear */
4067-
0, /* tp_richcompare */
4068-
0, /* tp_weaklistoffset */
4069-
PyObject_SelfIter, /* tp_iter */
4070-
(iternextfunc)filterfalse_next, /* tp_iternext */
4071-
filterfalse_methods, /* tp_methods */
4072-
0, /* tp_members */
4073-
0, /* tp_getset */
4074-
0, /* tp_base */
4075-
0, /* tp_dict */
4076-
0, /* tp_descr_get */
4077-
0, /* tp_descr_set */
4078-
0, /* tp_dictoffset */
4079-
0, /* tp_init */
4080-
0, /* tp_alloc */
4081-
itertools_filterfalse, /* tp_new */
4082-
PyObject_GC_Del, /* tp_free */
4044+
static PyType_Slot filterfalse_slots[] = {
4045+
{Py_tp_dealloc, filterfalse_dealloc},
4046+
{Py_tp_getattro, PyObject_GenericGetAttr},
4047+
{Py_tp_doc, (void *)itertools_filterfalse__doc__},
4048+
{Py_tp_traverse, filterfalse_traverse},
4049+
{Py_tp_iter, PyObject_SelfIter},
4050+
{Py_tp_iternext, filterfalse_next},
4051+
{Py_tp_methods, filterfalse_methods},
4052+
{Py_tp_new, itertools_filterfalse},
4053+
{Py_tp_free, PyObject_GC_Del},
4054+
{0, NULL},
4055+
};
4056+
4057+
static PyType_Spec filterfalse_spec = {
4058+
.name = "itertools.filterfalse",
4059+
.basicsize = sizeof(filterfalseobject),
4060+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
4061+
Py_TPFLAGS_IMMUTABLETYPE),
4062+
.slots = filterfalse_slots,
40834063
};
40844064

40854065

@@ -4801,6 +4781,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
48014781
Py_VISIT(state->cwr_type);
48024782
Py_VISIT(state->cycle_type);
48034783
Py_VISIT(state->dropwhile_type);
4784+
Py_VISIT(state->filterfalse_type);
48044785
Py_VISIT(state->groupby_type);
48054786
Py_VISIT(state->_grouper_type);
48064787
Py_VISIT(state->permutations_type);
@@ -4819,6 +4800,7 @@ itertoolsmodule_clear(PyObject *mod)
48194800
Py_CLEAR(state->cwr_type);
48204801
Py_CLEAR(state->cycle_type);
48214802
Py_CLEAR(state->dropwhile_type);
4803+
Py_CLEAR(state->filterfalse_type);
48224804
Py_CLEAR(state->groupby_type);
48234805
Py_CLEAR(state->_grouper_type);
48244806
Py_CLEAR(state->permutations_type);
@@ -4854,6 +4836,7 @@ itertoolsmodule_exec(PyObject *mod)
48544836
ADD_TYPE(mod, state->cwr_type, &cwr_spec);
48554837
ADD_TYPE(mod, state->cycle_type, &cycle_spec);
48564838
ADD_TYPE(mod, state->dropwhile_type, &dropwhile_spec);
4839+
ADD_TYPE(mod, state->filterfalse_type, &filterfalse_spec);
48574840
ADD_TYPE(mod, state->groupby_type, &groupby_spec);
48584841
ADD_TYPE(mod, state->_grouper_type, &_grouper_spec);
48594842
ADD_TYPE(mod, state->permutations_type, &permutations_spec);
@@ -4864,7 +4847,6 @@ itertoolsmodule_exec(PyObject *mod)
48644847
&batched_type,
48654848
&islice_type,
48664849
&chain_type,
4867-
&filterfalse_type,
48684850
&count_type,
48694851
&ziplongest_type,
48704852
&pairwise_type,

0 commit comments

Comments
 (0)