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 ;
@@ -3830,15 +3830,18 @@ itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2)
3830
3830
static void
3831
3831
compress_dealloc (compressobject * lz )
3832
3832
{
3833
+ PyTypeObject * tp = Py_TYPE (lz );
3833
3834
PyObject_GC_UnTrack (lz );
3834
3835
Py_XDECREF (lz -> data );
3835
3836
Py_XDECREF (lz -> selectors );
3836
- Py_TYPE (lz )-> tp_free (lz );
3837
+ tp -> tp_free (lz );
3838
+ Py_DECREF (tp );
3837
3839
}
3838
3840
3839
3841
static int
3840
3842
compress_traverse (compressobject * lz , visitproc visit , void * arg )
3841
3843
{
3844
+ Py_VISIT (Py_TYPE (lz ));
3842
3845
Py_VISIT (lz -> data );
3843
3846
Py_VISIT (lz -> selectors );
3844
3847
return 0 ;
@@ -3893,48 +3896,25 @@ static PyMethodDef compress_methods[] = {
3893
3896
{NULL , NULL } /* sentinel */
3894
3897
};
3895
3898
3896
- static PyTypeObject compress_type = {
3897
- PyVarObject_HEAD_INIT (NULL , 0 )
3898
- "itertools.compress" , /* tp_name */
3899
- sizeof (compressobject ), /* tp_basicsize */
3900
- 0 , /* tp_itemsize */
3901
- /* methods */
3902
- (destructor )compress_dealloc , /* tp_dealloc */
3903
- 0 , /* tp_vectorcall_offset */
3904
- 0 , /* tp_getattr */
3905
- 0 , /* tp_setattr */
3906
- 0 , /* tp_as_async */
3907
- 0 , /* tp_repr */
3908
- 0 , /* tp_as_number */
3909
- 0 , /* tp_as_sequence */
3910
- 0 , /* tp_as_mapping */
3911
- 0 , /* tp_hash */
3912
- 0 , /* tp_call */
3913
- 0 , /* tp_str */
3914
- PyObject_GenericGetAttr , /* tp_getattro */
3915
- 0 , /* tp_setattro */
3916
- 0 , /* tp_as_buffer */
3917
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3918
- Py_TPFLAGS_BASETYPE , /* tp_flags */
3919
- itertools_compress__doc__ , /* tp_doc */
3920
- (traverseproc )compress_traverse , /* tp_traverse */
3921
- 0 , /* tp_clear */
3922
- 0 , /* tp_richcompare */
3923
- 0 , /* tp_weaklistoffset */
3924
- PyObject_SelfIter , /* tp_iter */
3925
- (iternextfunc )compress_next , /* tp_iternext */
3926
- compress_methods , /* tp_methods */
3927
- 0 , /* tp_members */
3928
- 0 , /* tp_getset */
3929
- 0 , /* tp_base */
3930
- 0 , /* tp_dict */
3931
- 0 , /* tp_descr_get */
3932
- 0 , /* tp_descr_set */
3933
- 0 , /* tp_dictoffset */
3934
- 0 , /* tp_init */
3935
- 0 , /* tp_alloc */
3936
- itertools_compress , /* tp_new */
3937
- PyObject_GC_Del , /* tp_free */
3899
+ static PyType_Slot compress_slots [] = {
3900
+ {Py_tp_dealloc , compress_dealloc },
3901
+ {Py_tp_getattro , PyObject_GenericGetAttr },
3902
+ {Py_tp_doc , (void * )itertools_compress__doc__ },
3903
+ {Py_tp_traverse , compress_traverse },
3904
+ {Py_tp_iter , PyObject_SelfIter },
3905
+ {Py_tp_iternext , compress_next },
3906
+ {Py_tp_methods , compress_methods },
3907
+ {Py_tp_new , itertools_compress },
3908
+ {Py_tp_free , PyObject_GC_Del },
3909
+ {0 , NULL },
3910
+ };
3911
+
3912
+ static PyType_Spec compress_spec = {
3913
+ .name = "itertools.compress" ,
3914
+ .basicsize = sizeof (compressobject ),
3915
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
3916
+ Py_TPFLAGS_IMMUTABLETYPE ),
3917
+ .slots = compress_slots ,
3938
3918
};
3939
3919
3940
3920
@@ -4803,6 +4783,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4803
4783
itertools_state * state = get_module_state (mod );
4804
4784
Py_VISIT (state -> accumulate_type );
4805
4785
Py_VISIT (state -> combinations_type );
4786
+ Py_VISIT (state -> compress_type );
4806
4787
Py_VISIT (state -> cwr_type );
4807
4788
Py_VISIT (state -> cycle_type );
4808
4789
Py_VISIT (state -> dropwhile_type );
@@ -4820,6 +4801,7 @@ itertoolsmodule_clear(PyObject *mod)
4820
4801
itertools_state * state = get_module_state (mod );
4821
4802
Py_CLEAR (state -> accumulate_type );
4822
4803
Py_CLEAR (state -> combinations_type );
4804
+ Py_CLEAR (state -> compress_type );
4823
4805
Py_CLEAR (state -> cwr_type );
4824
4806
Py_CLEAR (state -> cycle_type );
4825
4807
Py_CLEAR (state -> dropwhile_type );
@@ -4854,6 +4836,7 @@ itertoolsmodule_exec(PyObject *mod)
4854
4836
itertools_state * state = get_module_state (mod );
4855
4837
ADD_TYPE (mod , state -> accumulate_type , & accumulate_spec );
4856
4838
ADD_TYPE (mod , state -> combinations_type , & combinations_spec );
4839
+ ADD_TYPE (mod , state -> compress_type , & compress_spec );
4857
4840
ADD_TYPE (mod , state -> cwr_type , & cwr_spec );
4858
4841
ADD_TYPE (mod , state -> cycle_type , & cycle_spec );
4859
4842
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
@@ -4867,7 +4850,6 @@ itertoolsmodule_exec(PyObject *mod)
4867
4850
& batched_type ,
4868
4851
& islice_type ,
4869
4852
& chain_type ,
4870
- & compress_type ,
4871
4853
& filterfalse_type ,
4872
4854
& count_type ,
4873
4855
& ziplongest_type ,
0 commit comments