13
13
typedef struct {
14
14
PyTypeObject * accumulate_type ;
15
15
PyTypeObject * combinations_type ;
16
+ PyTypeObject * compress_type ;
16
17
PyTypeObject * cwr_type ;
17
18
PyTypeObject * cycle_type ;
18
19
PyTypeObject * dropwhile_type ;
@@ -57,17 +58,16 @@ class itertools.combinations "combinationsobject *" "clinic_state()->combination
57
58
class itertools.combinations_with_replacement "cwr_object *" "clinic_state()->cwr_type"
58
59
class itertools.permutations "permutationsobject *" "clinic_state()->permutations_type"
59
60
class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type"
60
- class itertools.compress "compressobject *" "& compress_type"
61
+ class itertools.compress "compressobject *" "clinic_state()-> compress_type"
61
62
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
62
63
class itertools.count "countobject *" "&count_type"
63
64
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
64
65
[clinic start generated code]*/
65
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e0155dd6d01d40dd ]*/
66
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=18f0df1fc6fbed08 ]*/
66
67
67
68
static PyTypeObject teedataobject_type ;
68
69
static PyTypeObject tee_type ;
69
70
static PyTypeObject batched_type ;
70
- static PyTypeObject compress_type ;
71
71
static PyTypeObject filterfalse_type ;
72
72
static PyTypeObject count_type ;
73
73
static PyTypeObject pairwise_type ;
@@ -3831,15 +3831,18 @@ itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2)
3831
3831
static void
3832
3832
compress_dealloc (compressobject * lz )
3833
3833
{
3834
+ PyTypeObject * tp = Py_TYPE (lz );
3834
3835
PyObject_GC_UnTrack (lz );
3835
3836
Py_XDECREF (lz -> data );
3836
3837
Py_XDECREF (lz -> selectors );
3837
- Py_TYPE (lz )-> tp_free (lz );
3838
+ tp -> tp_free (lz );
3839
+ Py_DECREF (tp );
3838
3840
}
3839
3841
3840
3842
static int
3841
3843
compress_traverse (compressobject * lz , visitproc visit , void * arg )
3842
3844
{
3845
+ Py_VISIT (Py_TYPE (lz ));
3843
3846
Py_VISIT (lz -> data );
3844
3847
Py_VISIT (lz -> selectors );
3845
3848
return 0 ;
@@ -3894,48 +3897,25 @@ static PyMethodDef compress_methods[] = {
3894
3897
{NULL , NULL } /* sentinel */
3895
3898
};
3896
3899
3897
- static PyTypeObject compress_type = {
3898
- PyVarObject_HEAD_INIT (NULL , 0 )
3899
- "itertools.compress" , /* tp_name */
3900
- sizeof (compressobject ), /* tp_basicsize */
3901
- 0 , /* tp_itemsize */
3902
- /* methods */
3903
- (destructor )compress_dealloc , /* tp_dealloc */
3904
- 0 , /* tp_vectorcall_offset */
3905
- 0 , /* tp_getattr */
3906
- 0 , /* tp_setattr */
3907
- 0 , /* tp_as_async */
3908
- 0 , /* tp_repr */
3909
- 0 , /* tp_as_number */
3910
- 0 , /* tp_as_sequence */
3911
- 0 , /* tp_as_mapping */
3912
- 0 , /* tp_hash */
3913
- 0 , /* tp_call */
3914
- 0 , /* tp_str */
3915
- PyObject_GenericGetAttr , /* tp_getattro */
3916
- 0 , /* tp_setattro */
3917
- 0 , /* tp_as_buffer */
3918
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3919
- Py_TPFLAGS_BASETYPE , /* tp_flags */
3920
- itertools_compress__doc__ , /* tp_doc */
3921
- (traverseproc )compress_traverse , /* tp_traverse */
3922
- 0 , /* tp_clear */
3923
- 0 , /* tp_richcompare */
3924
- 0 , /* tp_weaklistoffset */
3925
- PyObject_SelfIter , /* tp_iter */
3926
- (iternextfunc )compress_next , /* tp_iternext */
3927
- compress_methods , /* tp_methods */
3928
- 0 , /* tp_members */
3929
- 0 , /* tp_getset */
3930
- 0 , /* tp_base */
3931
- 0 , /* tp_dict */
3932
- 0 , /* tp_descr_get */
3933
- 0 , /* tp_descr_set */
3934
- 0 , /* tp_dictoffset */
3935
- 0 , /* tp_init */
3936
- 0 , /* tp_alloc */
3937
- itertools_compress , /* tp_new */
3938
- PyObject_GC_Del , /* tp_free */
3900
+ static PyType_Slot compress_slots [] = {
3901
+ {Py_tp_dealloc , compress_dealloc },
3902
+ {Py_tp_getattro , PyObject_GenericGetAttr },
3903
+ {Py_tp_doc , (void * )itertools_compress__doc__ },
3904
+ {Py_tp_traverse , compress_traverse },
3905
+ {Py_tp_iter , PyObject_SelfIter },
3906
+ {Py_tp_iternext , compress_next },
3907
+ {Py_tp_methods , compress_methods },
3908
+ {Py_tp_new , itertools_compress },
3909
+ {Py_tp_free , PyObject_GC_Del },
3910
+ {0 , NULL },
3911
+ };
3912
+
3913
+ static PyType_Spec compress_spec = {
3914
+ .name = "itertools.compress" ,
3915
+ .basicsize = sizeof (compressobject ),
3916
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
3917
+ Py_TPFLAGS_IMMUTABLETYPE ),
3918
+ .slots = compress_slots ,
3939
3919
};
3940
3920
3941
3921
@@ -4804,6 +4784,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4804
4784
itertools_state * state = get_module_state (mod );
4805
4785
Py_VISIT (state -> accumulate_type );
4806
4786
Py_VISIT (state -> combinations_type );
4787
+ Py_VISIT (state -> compress_type );
4807
4788
Py_VISIT (state -> cwr_type );
4808
4789
Py_VISIT (state -> cycle_type );
4809
4790
Py_VISIT (state -> dropwhile_type );
@@ -4821,6 +4802,7 @@ itertoolsmodule_clear(PyObject *mod)
4821
4802
itertools_state * state = get_module_state (mod );
4822
4803
Py_CLEAR (state -> accumulate_type );
4823
4804
Py_CLEAR (state -> combinations_type );
4805
+ Py_CLEAR (state -> compress_type );
4824
4806
Py_CLEAR (state -> cwr_type );
4825
4807
Py_CLEAR (state -> cycle_type );
4826
4808
Py_CLEAR (state -> dropwhile_type );
@@ -4855,6 +4837,7 @@ itertoolsmodule_exec(PyObject *mod)
4855
4837
itertools_state * state = get_module_state (mod );
4856
4838
ADD_TYPE (mod , state -> accumulate_type , & accumulate_spec );
4857
4839
ADD_TYPE (mod , state -> combinations_type , & combinations_spec );
4840
+ ADD_TYPE (mod , state -> compress_type , & compress_spec );
4858
4841
ADD_TYPE (mod , state -> cwr_type , & cwr_spec );
4859
4842
ADD_TYPE (mod , state -> cycle_type , & cycle_spec );
4860
4843
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
@@ -4868,7 +4851,6 @@ itertoolsmodule_exec(PyObject *mod)
4868
4851
& batched_type ,
4869
4852
& islice_type ,
4870
4853
& chain_type ,
4871
- & compress_type ,
4872
4854
& filterfalse_type ,
4873
4855
& count_type ,
4874
4856
& ziplongest_type ,
0 commit comments