@@ -15,6 +15,7 @@ typedef struct {
15
15
PyTypeObject * accumulate_type ;
16
16
PyTypeObject * combinations_type ;
17
17
PyTypeObject * compress_type ;
18
+ PyTypeObject * count_type ;
18
19
PyTypeObject * cwr_type ;
19
20
PyTypeObject * cycle_type ;
20
21
PyTypeObject * dropwhile_type ;
@@ -71,15 +72,14 @@ class itertools.permutations "permutationsobject *" "clinic_state()->permutation
71
72
class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type"
72
73
class itertools.compress "compressobject *" "clinic_state()->compress_type"
73
74
class itertools.filterfalse "filterfalseobject *" "clinic_state()->filterfalse_type"
74
- class itertools.count "countobject *" "& count_type"
75
+ class itertools.count "countobject *" "clinic_state()-> count_type"
75
76
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
76
77
[clinic start generated code]*/
77
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=041cf92c608e0a3b ]*/
78
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=338b4d26465f3eb1 ]*/
78
79
79
80
static PyTypeObject teedataobject_type ;
80
81
static PyTypeObject tee_type ;
81
82
static PyTypeObject batched_type ;
82
- static PyTypeObject count_type ;
83
83
static PyTypeObject pairwise_type ;
84
84
85
85
#define clinic_state_by_cls () (get_module_state_by_cls(base_tp))
@@ -4185,15 +4185,18 @@ itertools_count_impl(PyTypeObject *type, PyObject *long_cnt,
4185
4185
static void
4186
4186
count_dealloc (countobject * lz )
4187
4187
{
4188
+ PyTypeObject * tp = Py_TYPE (lz );
4188
4189
PyObject_GC_UnTrack (lz );
4189
4190
Py_XDECREF (lz -> long_cnt );
4190
4191
Py_XDECREF (lz -> long_step );
4191
- Py_TYPE (lz )-> tp_free (lz );
4192
+ tp -> tp_free (lz );
4193
+ Py_DECREF (tp );
4192
4194
}
4193
4195
4194
4196
static int
4195
4197
count_traverse (countobject * lz , visitproc visit , void * arg )
4196
4198
{
4199
+ Py_VISIT (Py_TYPE (lz ));
4197
4200
Py_VISIT (lz -> long_cnt );
4198
4201
Py_VISIT (lz -> long_step );
4199
4202
return 0 ;
@@ -4267,48 +4270,26 @@ static PyMethodDef count_methods[] = {
4267
4270
{NULL , NULL } /* sentinel */
4268
4271
};
4269
4272
4270
- static PyTypeObject count_type = {
4271
- PyVarObject_HEAD_INIT (NULL , 0 )
4272
- "itertools.count" , /* tp_name */
4273
- sizeof (countobject ), /* tp_basicsize */
4274
- 0 , /* tp_itemsize */
4275
- /* methods */
4276
- (destructor )count_dealloc , /* tp_dealloc */
4277
- 0 , /* tp_vectorcall_offset */
4278
- 0 , /* tp_getattr */
4279
- 0 , /* tp_setattr */
4280
- 0 , /* tp_as_async */
4281
- (reprfunc )count_repr , /* tp_repr */
4282
- 0 , /* tp_as_number */
4283
- 0 , /* tp_as_sequence */
4284
- 0 , /* tp_as_mapping */
4285
- 0 , /* tp_hash */
4286
- 0 , /* tp_call */
4287
- 0 , /* tp_str */
4288
- PyObject_GenericGetAttr , /* tp_getattro */
4289
- 0 , /* tp_setattro */
4290
- 0 , /* tp_as_buffer */
4291
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
4292
- Py_TPFLAGS_BASETYPE , /* tp_flags */
4293
- itertools_count__doc__ , /* tp_doc */
4294
- (traverseproc )count_traverse , /* tp_traverse */
4295
- 0 , /* tp_clear */
4296
- 0 , /* tp_richcompare */
4297
- 0 , /* tp_weaklistoffset */
4298
- PyObject_SelfIter , /* tp_iter */
4299
- (iternextfunc )count_next , /* tp_iternext */
4300
- count_methods , /* tp_methods */
4301
- 0 , /* tp_members */
4302
- 0 , /* tp_getset */
4303
- 0 , /* tp_base */
4304
- 0 , /* tp_dict */
4305
- 0 , /* tp_descr_get */
4306
- 0 , /* tp_descr_set */
4307
- 0 , /* tp_dictoffset */
4308
- 0 , /* tp_init */
4309
- 0 , /* tp_alloc */
4310
- itertools_count , /* tp_new */
4311
- PyObject_GC_Del , /* tp_free */
4273
+ static PyType_Slot count_slots [] = {
4274
+ {Py_tp_dealloc , count_dealloc },
4275
+ {Py_tp_repr , count_repr },
4276
+ {Py_tp_getattro , PyObject_GenericGetAttr },
4277
+ {Py_tp_doc , (void * )itertools_count__doc__ },
4278
+ {Py_tp_traverse , count_traverse },
4279
+ {Py_tp_iter , PyObject_SelfIter },
4280
+ {Py_tp_iternext , count_next },
4281
+ {Py_tp_methods , count_methods },
4282
+ {Py_tp_new , itertools_count },
4283
+ {Py_tp_free , PyObject_GC_Del },
4284
+ {0 , NULL },
4285
+ };
4286
+
4287
+ static PyType_Spec count_spec = {
4288
+ .name = "itertools.count" ,
4289
+ .basicsize = sizeof (countobject ),
4290
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
4291
+ Py_TPFLAGS_IMMUTABLETYPE ),
4292
+ .slots = count_slots ,
4312
4293
};
4313
4294
4314
4295
@@ -4778,6 +4759,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4778
4759
Py_VISIT (state -> accumulate_type );
4779
4760
Py_VISIT (state -> combinations_type );
4780
4761
Py_VISIT (state -> compress_type );
4762
+ Py_VISIT (state -> count_type );
4781
4763
Py_VISIT (state -> cwr_type );
4782
4764
Py_VISIT (state -> cycle_type );
4783
4765
Py_VISIT (state -> dropwhile_type );
@@ -4797,6 +4779,7 @@ itertoolsmodule_clear(PyObject *mod)
4797
4779
Py_CLEAR (state -> accumulate_type );
4798
4780
Py_CLEAR (state -> combinations_type );
4799
4781
Py_CLEAR (state -> compress_type );
4782
+ Py_CLEAR (state -> count_type );
4800
4783
Py_CLEAR (state -> cwr_type );
4801
4784
Py_CLEAR (state -> cycle_type );
4802
4785
Py_CLEAR (state -> dropwhile_type );
@@ -4833,6 +4816,7 @@ itertoolsmodule_exec(PyObject *mod)
4833
4816
ADD_TYPE (mod , state -> accumulate_type , & accumulate_spec );
4834
4817
ADD_TYPE (mod , state -> combinations_type , & combinations_spec );
4835
4818
ADD_TYPE (mod , state -> compress_type , & compress_spec );
4819
+ ADD_TYPE (mod , state -> count_type , & count_spec );
4836
4820
ADD_TYPE (mod , state -> cwr_type , & cwr_spec );
4837
4821
ADD_TYPE (mod , state -> cycle_type , & cycle_spec );
4838
4822
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
@@ -4847,7 +4831,6 @@ itertoolsmodule_exec(PyObject *mod)
4847
4831
& batched_type ,
4848
4832
& islice_type ,
4849
4833
& chain_type ,
4850
- & count_type ,
4851
4834
& ziplongest_type ,
4852
4835
& pairwise_type ,
4853
4836
& product_type ,
0 commit comments