14
14
typedef struct {
15
15
PyTypeObject * accumulate_type ;
16
16
PyTypeObject * combinations_type ;
17
+ PyTypeObject * compress_type ;
17
18
PyTypeObject * cwr_type ;
18
19
PyTypeObject * cycle_type ;
19
20
PyTypeObject * dropwhile_type ;
@@ -67,17 +68,16 @@ class itertools.combinations "combinationsobject *" "clinic_state()->combination
67
68
class itertools.combinations_with_replacement "cwr_object *" "clinic_state()->cwr_type"
68
69
class itertools.permutations "permutationsobject *" "clinic_state()->permutations_type"
69
70
class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type"
70
- class itertools.compress "compressobject *" "& compress_type"
71
+ class itertools.compress "compressobject *" "clinic_state()-> compress_type"
71
72
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
72
73
class itertools.count "countobject *" "&count_type"
73
74
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
74
75
[clinic start generated code]*/
75
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e0155dd6d01d40dd ]*/
76
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=18f0df1fc6fbed08 ]*/
76
77
77
78
static PyTypeObject teedataobject_type ;
78
79
static PyTypeObject tee_type ;
79
80
static PyTypeObject batched_type ;
80
- static PyTypeObject compress_type ;
81
81
static PyTypeObject filterfalse_type ;
82
82
static PyTypeObject count_type ;
83
83
static PyTypeObject pairwise_type ;
@@ -3844,15 +3844,18 @@ itertools_compress_impl(PyTypeObject *type, PyObject *seq1, PyObject *seq2)
3844
3844
static void
3845
3845
compress_dealloc (compressobject * lz )
3846
3846
{
3847
+ PyTypeObject * tp = Py_TYPE (lz );
3847
3848
PyObject_GC_UnTrack (lz );
3848
3849
Py_XDECREF (lz -> data );
3849
3850
Py_XDECREF (lz -> selectors );
3850
- Py_TYPE (lz )-> tp_free (lz );
3851
+ tp -> tp_free (lz );
3852
+ Py_DECREF (tp );
3851
3853
}
3852
3854
3853
3855
static int
3854
3856
compress_traverse (compressobject * lz , visitproc visit , void * arg )
3855
3857
{
3858
+ Py_VISIT (Py_TYPE (lz ));
3856
3859
Py_VISIT (lz -> data );
3857
3860
Py_VISIT (lz -> selectors );
3858
3861
return 0 ;
@@ -3907,48 +3910,25 @@ static PyMethodDef compress_methods[] = {
3907
3910
{NULL , NULL } /* sentinel */
3908
3911
};
3909
3912
3910
- static PyTypeObject compress_type = {
3911
- PyVarObject_HEAD_INIT (NULL , 0 )
3912
- "itertools.compress" , /* tp_name */
3913
- sizeof (compressobject ), /* tp_basicsize */
3914
- 0 , /* tp_itemsize */
3915
- /* methods */
3916
- (destructor )compress_dealloc , /* tp_dealloc */
3917
- 0 , /* tp_vectorcall_offset */
3918
- 0 , /* tp_getattr */
3919
- 0 , /* tp_setattr */
3920
- 0 , /* tp_as_async */
3921
- 0 , /* tp_repr */
3922
- 0 , /* tp_as_number */
3923
- 0 , /* tp_as_sequence */
3924
- 0 , /* tp_as_mapping */
3925
- 0 , /* tp_hash */
3926
- 0 , /* tp_call */
3927
- 0 , /* tp_str */
3928
- PyObject_GenericGetAttr , /* tp_getattro */
3929
- 0 , /* tp_setattro */
3930
- 0 , /* tp_as_buffer */
3931
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3932
- Py_TPFLAGS_BASETYPE , /* tp_flags */
3933
- itertools_compress__doc__ , /* tp_doc */
3934
- (traverseproc )compress_traverse , /* tp_traverse */
3935
- 0 , /* tp_clear */
3936
- 0 , /* tp_richcompare */
3937
- 0 , /* tp_weaklistoffset */
3938
- PyObject_SelfIter , /* tp_iter */
3939
- (iternextfunc )compress_next , /* tp_iternext */
3940
- compress_methods , /* tp_methods */
3941
- 0 , /* tp_members */
3942
- 0 , /* tp_getset */
3943
- 0 , /* tp_base */
3944
- 0 , /* tp_dict */
3945
- 0 , /* tp_descr_get */
3946
- 0 , /* tp_descr_set */
3947
- 0 , /* tp_dictoffset */
3948
- 0 , /* tp_init */
3949
- 0 , /* tp_alloc */
3950
- itertools_compress , /* tp_new */
3951
- PyObject_GC_Del , /* tp_free */
3913
+ static PyType_Slot compress_slots [] = {
3914
+ {Py_tp_dealloc , compress_dealloc },
3915
+ {Py_tp_getattro , PyObject_GenericGetAttr },
3916
+ {Py_tp_doc , (void * )itertools_compress__doc__ },
3917
+ {Py_tp_traverse , compress_traverse },
3918
+ {Py_tp_iter , PyObject_SelfIter },
3919
+ {Py_tp_iternext , compress_next },
3920
+ {Py_tp_methods , compress_methods },
3921
+ {Py_tp_new , itertools_compress },
3922
+ {Py_tp_free , PyObject_GC_Del },
3923
+ {0 , NULL },
3924
+ };
3925
+
3926
+ static PyType_Spec compress_spec = {
3927
+ .name = "itertools.compress" ,
3928
+ .basicsize = sizeof (compressobject ),
3929
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
3930
+ Py_TPFLAGS_IMMUTABLETYPE ),
3931
+ .slots = compress_slots ,
3952
3932
};
3953
3933
3954
3934
@@ -4817,6 +4797,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4817
4797
itertools_state * state = get_module_state (mod );
4818
4798
Py_VISIT (state -> accumulate_type );
4819
4799
Py_VISIT (state -> combinations_type );
4800
+ Py_VISIT (state -> compress_type );
4820
4801
Py_VISIT (state -> cwr_type );
4821
4802
Py_VISIT (state -> cycle_type );
4822
4803
Py_VISIT (state -> dropwhile_type );
@@ -4834,6 +4815,7 @@ itertoolsmodule_clear(PyObject *mod)
4834
4815
itertools_state * state = get_module_state (mod );
4835
4816
Py_CLEAR (state -> accumulate_type );
4836
4817
Py_CLEAR (state -> combinations_type );
4818
+ Py_CLEAR (state -> compress_type );
4837
4819
Py_CLEAR (state -> cwr_type );
4838
4820
Py_CLEAR (state -> cycle_type );
4839
4821
Py_CLEAR (state -> dropwhile_type );
@@ -4868,6 +4850,7 @@ itertoolsmodule_exec(PyObject *mod)
4868
4850
itertools_state * state = get_module_state (mod );
4869
4851
ADD_TYPE (mod , state -> accumulate_type , & accumulate_spec );
4870
4852
ADD_TYPE (mod , state -> combinations_type , & combinations_spec );
4853
+ ADD_TYPE (mod , state -> compress_type , & compress_spec );
4871
4854
ADD_TYPE (mod , state -> cwr_type , & cwr_spec );
4872
4855
ADD_TYPE (mod , state -> cycle_type , & cycle_spec );
4873
4856
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
@@ -4881,7 +4864,6 @@ itertoolsmodule_exec(PyObject *mod)
4881
4864
& batched_type ,
4882
4865
& islice_type ,
4883
4866
& chain_type ,
4884
- & compress_type ,
4885
4867
& filterfalse_type ,
4886
4868
& count_type ,
4887
4869
& ziplongest_type ,
0 commit comments