@@ -14,6 +14,7 @@ typedef struct {
14
14
PyTypeObject * accumulate_type ;
15
15
PyTypeObject * combinations_type ;
16
16
PyTypeObject * compress_type ;
17
+ PyTypeObject * count_type ;
17
18
PyTypeObject * cwr_type ;
18
19
PyTypeObject * cycle_type ;
19
20
PyTypeObject * dropwhile_type ;
@@ -61,15 +62,14 @@ class itertools.permutations "permutationsobject *" "clinic_state()->permutation
61
62
class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type"
62
63
class itertools.compress "compressobject *" "clinic_state()->compress_type"
63
64
class itertools.filterfalse "filterfalseobject *" "clinic_state()->filterfalse_type"
64
- class itertools.count "countobject *" "& count_type"
65
+ class itertools.count "countobject *" "clinic_state()-> count_type"
65
66
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
66
67
[clinic start generated code]*/
67
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=041cf92c608e0a3b ]*/
68
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=338b4d26465f3eb1 ]*/
68
69
69
70
static PyTypeObject teedataobject_type ;
70
71
static PyTypeObject tee_type ;
71
72
static PyTypeObject batched_type ;
72
- static PyTypeObject count_type ;
73
73
static PyTypeObject pairwise_type ;
74
74
75
75
#include "clinic/itertoolsmodule.c.h"
@@ -4171,15 +4171,18 @@ itertools_count_impl(PyTypeObject *type, PyObject *long_cnt,
4171
4171
static void
4172
4172
count_dealloc (countobject * lz )
4173
4173
{
4174
+ PyTypeObject * tp = Py_TYPE (lz );
4174
4175
PyObject_GC_UnTrack (lz );
4175
4176
Py_XDECREF (lz -> long_cnt );
4176
4177
Py_XDECREF (lz -> long_step );
4177
- Py_TYPE (lz )-> tp_free (lz );
4178
+ tp -> tp_free (lz );
4179
+ Py_DECREF (tp );
4178
4180
}
4179
4181
4180
4182
static int
4181
4183
count_traverse (countobject * lz , visitproc visit , void * arg )
4182
4184
{
4185
+ Py_VISIT (Py_TYPE (lz ));
4183
4186
Py_VISIT (lz -> long_cnt );
4184
4187
Py_VISIT (lz -> long_step );
4185
4188
return 0 ;
@@ -4253,48 +4256,26 @@ static PyMethodDef count_methods[] = {
4253
4256
{NULL , NULL } /* sentinel */
4254
4257
};
4255
4258
4256
- static PyTypeObject count_type = {
4257
- PyVarObject_HEAD_INIT (NULL , 0 )
4258
- "itertools.count" , /* tp_name */
4259
- sizeof (countobject ), /* tp_basicsize */
4260
- 0 , /* tp_itemsize */
4261
- /* methods */
4262
- (destructor )count_dealloc , /* tp_dealloc */
4263
- 0 , /* tp_vectorcall_offset */
4264
- 0 , /* tp_getattr */
4265
- 0 , /* tp_setattr */
4266
- 0 , /* tp_as_async */
4267
- (reprfunc )count_repr , /* tp_repr */
4268
- 0 , /* tp_as_number */
4269
- 0 , /* tp_as_sequence */
4270
- 0 , /* tp_as_mapping */
4271
- 0 , /* tp_hash */
4272
- 0 , /* tp_call */
4273
- 0 , /* tp_str */
4274
- PyObject_GenericGetAttr , /* tp_getattro */
4275
- 0 , /* tp_setattro */
4276
- 0 , /* tp_as_buffer */
4277
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
4278
- Py_TPFLAGS_BASETYPE , /* tp_flags */
4279
- itertools_count__doc__ , /* tp_doc */
4280
- (traverseproc )count_traverse , /* tp_traverse */
4281
- 0 , /* tp_clear */
4282
- 0 , /* tp_richcompare */
4283
- 0 , /* tp_weaklistoffset */
4284
- PyObject_SelfIter , /* tp_iter */
4285
- (iternextfunc )count_next , /* tp_iternext */
4286
- count_methods , /* tp_methods */
4287
- 0 , /* tp_members */
4288
- 0 , /* tp_getset */
4289
- 0 , /* tp_base */
4290
- 0 , /* tp_dict */
4291
- 0 , /* tp_descr_get */
4292
- 0 , /* tp_descr_set */
4293
- 0 , /* tp_dictoffset */
4294
- 0 , /* tp_init */
4295
- 0 , /* tp_alloc */
4296
- itertools_count , /* tp_new */
4297
- PyObject_GC_Del , /* tp_free */
4259
+ static PyType_Slot count_slots [] = {
4260
+ {Py_tp_dealloc , count_dealloc },
4261
+ {Py_tp_repr , count_repr },
4262
+ {Py_tp_getattro , PyObject_GenericGetAttr },
4263
+ {Py_tp_doc , (void * )itertools_count__doc__ },
4264
+ {Py_tp_traverse , count_traverse },
4265
+ {Py_tp_iter , PyObject_SelfIter },
4266
+ {Py_tp_iternext , count_next },
4267
+ {Py_tp_methods , count_methods },
4268
+ {Py_tp_new , itertools_count },
4269
+ {Py_tp_free , PyObject_GC_Del },
4270
+ {0 , NULL },
4271
+ };
4272
+
4273
+ static PyType_Spec count_spec = {
4274
+ .name = "itertools.count" ,
4275
+ .basicsize = sizeof (countobject ),
4276
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
4277
+ Py_TPFLAGS_IMMUTABLETYPE ),
4278
+ .slots = count_slots ,
4298
4279
};
4299
4280
4300
4281
@@ -4764,6 +4745,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4764
4745
Py_VISIT (state -> accumulate_type );
4765
4746
Py_VISIT (state -> combinations_type );
4766
4747
Py_VISIT (state -> compress_type );
4748
+ Py_VISIT (state -> count_type );
4767
4749
Py_VISIT (state -> cwr_type );
4768
4750
Py_VISIT (state -> cycle_type );
4769
4751
Py_VISIT (state -> dropwhile_type );
@@ -4783,6 +4765,7 @@ itertoolsmodule_clear(PyObject *mod)
4783
4765
Py_CLEAR (state -> accumulate_type );
4784
4766
Py_CLEAR (state -> combinations_type );
4785
4767
Py_CLEAR (state -> compress_type );
4768
+ Py_CLEAR (state -> count_type );
4786
4769
Py_CLEAR (state -> cwr_type );
4787
4770
Py_CLEAR (state -> cycle_type );
4788
4771
Py_CLEAR (state -> dropwhile_type );
@@ -4819,6 +4802,7 @@ itertoolsmodule_exec(PyObject *mod)
4819
4802
ADD_TYPE (mod , state -> accumulate_type , & accumulate_spec );
4820
4803
ADD_TYPE (mod , state -> combinations_type , & combinations_spec );
4821
4804
ADD_TYPE (mod , state -> compress_type , & compress_spec );
4805
+ ADD_TYPE (mod , state -> count_type , & count_spec );
4822
4806
ADD_TYPE (mod , state -> cwr_type , & cwr_spec );
4823
4807
ADD_TYPE (mod , state -> cycle_type , & cycle_spec );
4824
4808
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
@@ -4833,7 +4817,6 @@ itertoolsmodule_exec(PyObject *mod)
4833
4817
& batched_type ,
4834
4818
& islice_type ,
4835
4819
& chain_type ,
4836
- & count_type ,
4837
4820
& ziplongest_type ,
4838
4821
& pairwise_type ,
4839
4822
& product_type ,
0 commit comments