@@ -21,6 +21,7 @@ typedef struct {
2121 PyTypeObject * filterfalse_type ;
2222 PyTypeObject * groupby_type ;
2323 PyTypeObject * _grouper_type ;
24+ PyTypeObject * pairwise_type ;
2425 PyTypeObject * permutations_type ;
2526 PyTypeObject * starmap_type ;
2627 PyTypeObject * takewhile_type ;
@@ -63,14 +64,13 @@ class itertools.accumulate "accumulateobject *" "clinic_state()->accumulate_type
6364class itertools.compress "compressobject *" "clinic_state()->compress_type"
6465class itertools.filterfalse "filterfalseobject *" "clinic_state()->filterfalse_type"
6566class itertools.count "countobject *" "clinic_state()->count_type"
66- class itertools.pairwise "pairwiseobject *" "& pairwise_type"
67+ class itertools.pairwise "pairwiseobject *" "clinic_state()-> pairwise_type"
6768[clinic start generated code]*/
68- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=338b4d26465f3eb1 ]*/
69+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=28ffff5c0c93eed7 ]*/
6970
7071static PyTypeObject teedataobject_type ;
7172static PyTypeObject tee_type ;
7273static PyTypeObject batched_type ;
73- static PyTypeObject pairwise_type ;
7474
7575#include "clinic/itertoolsmodule.c.h"
7676#undef clinic_state
@@ -296,15 +296,18 @@ pairwise_new_impl(PyTypeObject *type, PyObject *iterable)
296296static void
297297pairwise_dealloc (pairwiseobject * po )
298298{
299+ PyTypeObject * tp = Py_TYPE (po );
299300 PyObject_GC_UnTrack (po );
300301 Py_XDECREF (po -> it );
301302 Py_XDECREF (po -> old );
302- Py_TYPE (po )-> tp_free (po );
303+ tp -> tp_free (po );
304+ Py_DECREF (tp );
303305}
304306
305307static int
306308pairwise_traverse (pairwiseobject * po , visitproc visit , void * arg )
307309{
310+ Py_VISIT (Py_TYPE (po ));
308311 Py_VISIT (po -> it );
309312 Py_VISIT (po -> old );
310313 return 0 ;
@@ -339,48 +342,25 @@ pairwise_next(pairwiseobject *po)
339342 return result ;
340343}
341344
342- static PyTypeObject pairwise_type = {
343- PyVarObject_HEAD_INIT (& PyType_Type , 0 )
344- "itertools.pairwise" , /* tp_name */
345- sizeof (pairwiseobject ), /* tp_basicsize */
346- 0 , /* tp_itemsize */
347- /* methods */
348- (destructor )pairwise_dealloc , /* tp_dealloc */
349- 0 , /* tp_vectorcall_offset */
350- 0 , /* tp_getattr */
351- 0 , /* tp_setattr */
352- 0 , /* tp_as_async */
353- 0 , /* tp_repr */
354- 0 , /* tp_as_number */
355- 0 , /* tp_as_sequence */
356- 0 , /* tp_as_mapping */
357- 0 , /* tp_hash */
358- 0 , /* tp_call */
359- 0 , /* tp_str */
360- PyObject_GenericGetAttr , /* tp_getattro */
361- 0 , /* tp_setattro */
362- 0 , /* tp_as_buffer */
363- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
364- Py_TPFLAGS_BASETYPE , /* tp_flags */
365- pairwise_new__doc__ , /* tp_doc */
366- (traverseproc )pairwise_traverse , /* tp_traverse */
367- 0 , /* tp_clear */
368- 0 , /* tp_richcompare */
369- 0 , /* tp_weaklistoffset */
370- PyObject_SelfIter , /* tp_iter */
371- (iternextfunc )pairwise_next , /* tp_iternext */
372- 0 , /* tp_methods */
373- 0 , /* tp_members */
374- 0 , /* tp_getset */
375- 0 , /* tp_base */
376- 0 , /* tp_dict */
377- 0 , /* tp_descr_get */
378- 0 , /* tp_descr_set */
379- 0 , /* tp_dictoffset */
380- 0 , /* tp_init */
381- PyType_GenericAlloc , /* tp_alloc */
382- pairwise_new , /* tp_new */
383- PyObject_GC_Del , /* tp_free */
345+ static PyType_Slot pairwise_slots [] = {
346+ {Py_tp_dealloc , pairwise_dealloc },
347+ {Py_tp_getattro , PyObject_GenericGetAttr },
348+ {Py_tp_doc , (void * )pairwise_new__doc__ },
349+ {Py_tp_traverse , pairwise_traverse },
350+ {Py_tp_iter , PyObject_SelfIter },
351+ {Py_tp_iternext , pairwise_next },
352+ {Py_tp_alloc , PyType_GenericAlloc },
353+ {Py_tp_new , pairwise_new },
354+ {Py_tp_free , PyObject_GC_Del },
355+ {0 , NULL },
356+ };
357+
358+ static PyType_Spec pairwise_spec = {
359+ .name = "itertools.pairwise" ,
360+ .basicsize = sizeof (pairwiseobject ),
361+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
362+ Py_TPFLAGS_IMMUTABLETYPE ),
363+ .slots = pairwise_slots ,
384364};
385365
386366
@@ -4753,6 +4733,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
47534733 Py_VISIT (state -> filterfalse_type );
47544734 Py_VISIT (state -> groupby_type );
47554735 Py_VISIT (state -> _grouper_type );
4736+ Py_VISIT (state -> pairwise_type );
47564737 Py_VISIT (state -> permutations_type );
47574738 Py_VISIT (state -> starmap_type );
47584739 Py_VISIT (state -> takewhile_type );
@@ -4773,6 +4754,7 @@ itertoolsmodule_clear(PyObject *mod)
47734754 Py_CLEAR (state -> filterfalse_type );
47744755 Py_CLEAR (state -> groupby_type );
47754756 Py_CLEAR (state -> _grouper_type );
4757+ Py_CLEAR (state -> pairwise_type );
47764758 Py_CLEAR (state -> permutations_type );
47774759 Py_CLEAR (state -> starmap_type );
47784760 Py_CLEAR (state -> takewhile_type );
@@ -4810,6 +4792,7 @@ itertoolsmodule_exec(PyObject *mod)
48104792 ADD_TYPE (mod , state -> filterfalse_type , & filterfalse_spec );
48114793 ADD_TYPE (mod , state -> groupby_type , & groupby_spec );
48124794 ADD_TYPE (mod , state -> _grouper_type , & _grouper_spec );
4795+ ADD_TYPE (mod , state -> pairwise_type , & pairwise_spec );
48134796 ADD_TYPE (mod , state -> permutations_type , & permutations_spec );
48144797 ADD_TYPE (mod , state -> starmap_type , & starmap_spec );
48154798 ADD_TYPE (mod , state -> takewhile_type , & takewhile_spec );
@@ -4819,7 +4802,6 @@ itertoolsmodule_exec(PyObject *mod)
48194802 & islice_type ,
48204803 & chain_type ,
48214804 & ziplongest_type ,
4822- & pairwise_type ,
48234805 & product_type ,
48244806 & repeat_type ,
48254807 & tee_type ,
0 commit comments