Skip to content

Commit b29e885

Browse files
101277: Add filterfalse type to module state
1 parent 04e8c29 commit b29e885

File tree

2 files changed

+32
-50
lines changed

2 files changed

+32
-50
lines changed

Modules/clinic/itertoolsmodule.c.h

Lines changed: 3 additions & 3 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
@@ -17,6 +17,7 @@ typedef struct {
1717
PyTypeObject *cwr_type;
1818
PyTypeObject *cycle_type;
1919
PyTypeObject *dropwhile_type;
20+
PyTypeObject *filterfalse_type;
2021
PyTypeObject *groupby_type;
2122
PyTypeObject *_grouper_type;
2223
PyTypeObject *permutations_type;
@@ -59,16 +60,15 @@ class itertools.combinations_with_replacement "cwr_object *" "clinic_state()->cw
5960
class itertools.permutations "permutationsobject *" "clinic_state()->permutations_type"
6061
class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type"
6162
class itertools.compress "compressobject *" "clinic_state()->compress_type"
62-
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
63+
class itertools.filterfalse "filterfalseobject *" "clinic_state()->filterfalse_type"
6364
class itertools.count "countobject *" "&count_type"
6465
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
6566
[clinic start generated code]*/
66-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=18f0df1fc6fbed08]*/
67+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=041cf92c608e0a3b]*/
6768

6869
static PyTypeObject teedataobject_type;
6970
static PyTypeObject tee_type;
7071
static PyTypeObject batched_type;
71-
static PyTypeObject filterfalse_type;
7272
static PyTypeObject count_type;
7373
static PyTypeObject pairwise_type;
7474

@@ -3965,15 +3965,18 @@ itertools_filterfalse_impl(PyTypeObject *type, PyObject *func, PyObject *seq)
39653965
static void
39663966
filterfalse_dealloc(filterfalseobject *lz)
39673967
{
3968+
PyTypeObject *tp = Py_TYPE(lz);
39683969
PyObject_GC_UnTrack(lz);
39693970
Py_XDECREF(lz->func);
39703971
Py_XDECREF(lz->it);
3971-
Py_TYPE(lz)->tp_free(lz);
3972+
tp->tp_free(lz);
3973+
Py_DECREF(tp);
39723974
}
39733975

39743976
static int
39753977
filterfalse_traverse(filterfalseobject *lz, visitproc visit, void *arg)
39763978
{
3979+
Py_VISIT(Py_TYPE(lz));
39773980
Py_VISIT(lz->it);
39783981
Py_VISIT(lz->func);
39793982
return 0;
@@ -4025,48 +4028,25 @@ static PyMethodDef filterfalse_methods[] = {
40254028
{NULL, NULL} /* sentinel */
40264029
};
40274030

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

40724052

@@ -4788,6 +4768,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
47884768
Py_VISIT(state->cwr_type);
47894769
Py_VISIT(state->cycle_type);
47904770
Py_VISIT(state->dropwhile_type);
4771+
Py_VISIT(state->filterfalse_type);
47914772
Py_VISIT(state->groupby_type);
47924773
Py_VISIT(state->_grouper_type);
47934774
Py_VISIT(state->permutations_type);
@@ -4806,6 +4787,7 @@ itertoolsmodule_clear(PyObject *mod)
48064787
Py_CLEAR(state->cwr_type);
48074788
Py_CLEAR(state->cycle_type);
48084789
Py_CLEAR(state->dropwhile_type);
4790+
Py_CLEAR(state->filterfalse_type);
48094791
Py_CLEAR(state->groupby_type);
48104792
Py_CLEAR(state->_grouper_type);
48114793
Py_CLEAR(state->permutations_type);
@@ -4841,6 +4823,7 @@ itertoolsmodule_exec(PyObject *mod)
48414823
ADD_TYPE(mod, state->cwr_type, &cwr_spec);
48424824
ADD_TYPE(mod, state->cycle_type, &cycle_spec);
48434825
ADD_TYPE(mod, state->dropwhile_type, &dropwhile_spec);
4826+
ADD_TYPE(mod, state->filterfalse_type, &filterfalse_spec);
48444827
ADD_TYPE(mod, state->groupby_type, &groupby_spec);
48454828
ADD_TYPE(mod, state->_grouper_type, &_grouper_spec);
48464829
ADD_TYPE(mod, state->permutations_type, &permutations_spec);
@@ -4851,7 +4834,6 @@ itertoolsmodule_exec(PyObject *mod)
48514834
&batched_type,
48524835
&islice_type,
48534836
&chain_type,
4854-
&filterfalse_type,
48554837
&count_type,
48564838
&ziplongest_type,
48574839
&pairwise_type,

0 commit comments

Comments
 (0)