@@ -17,6 +17,7 @@ typedef struct {
1717 PyTypeObject * dropwhile_type ;
1818 PyTypeObject * groupby_type ;
1919 PyTypeObject * _grouper_type ;
20+ PyTypeObject * permutations_type ;
2021 PyTypeObject * starmap_type ;
2122 PyTypeObject * takewhile_type ;
2223} itertools_state ;
@@ -53,19 +54,18 @@ class itertools.starmap "starmapobject *" "clinic_state()->starmap_type"
5354class itertools.chain "chainobject *" "&chain_type"
5455class itertools.combinations "combinationsobject *" "clinic_state()->combinations_type"
5556class itertools.combinations_with_replacement "cwr_object *" "clinic_state()->cwr_type"
56- class itertools.permutations "permutationsobject *" "& permutations_type"
57+ class itertools.permutations "permutationsobject *" "clinic_state()-> permutations_type"
5758class itertools.accumulate "accumulateobject *" "&accumulate_type"
5859class itertools.compress "compressobject *" "&compress_type"
5960class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
6061class itertools.count "countobject *" "&count_type"
6162class itertools.pairwise "pairwiseobject *" "&pairwise_type"
6263[clinic start generated code]*/
63- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=d44fee9ebae461fb ]*/
64+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=1790ac655869a651 ]*/
6465
6566static PyTypeObject teedataobject_type ;
6667static PyTypeObject tee_type ;
6768static PyTypeObject batched_type ;
68- static PyTypeObject permutations_type ;
6969static PyTypeObject accumulate_type ;
7070static PyTypeObject compress_type ;
7171static PyTypeObject filterfalse_type ;
@@ -3342,12 +3342,14 @@ itertools_permutations_impl(PyTypeObject *type, PyObject *iterable,
33423342static void
33433343permutations_dealloc (permutationsobject * po )
33443344{
3345+ PyTypeObject * tp = Py_TYPE (po );
33453346 PyObject_GC_UnTrack (po );
33463347 Py_XDECREF (po -> pool );
33473348 Py_XDECREF (po -> result );
33483349 PyMem_Free (po -> indices );
33493350 PyMem_Free (po -> cycles );
3350- Py_TYPE (po )-> tp_free (po );
3351+ tp -> tp_free (po );
3352+ Py_DECREF (tp );
33513353}
33523354
33533355static PyObject *
@@ -3362,6 +3364,7 @@ permutations_sizeof(permutationsobject *po, void *unused)
33623364static int
33633365permutations_traverse (permutationsobject * po , visitproc visit , void * arg )
33643366{
3367+ Py_VISIT (Py_TYPE (po ));
33653368 Py_VISIT (po -> pool );
33663369 Py_VISIT (po -> result );
33673370 return 0 ;
@@ -3567,48 +3570,25 @@ static PyMethodDef permuations_methods[] = {
35673570 {NULL , NULL } /* sentinel */
35683571};
35693572
3570- static PyTypeObject permutations_type = {
3571- PyVarObject_HEAD_INIT (NULL , 0 )
3572- "itertools.permutations" , /* tp_name */
3573- sizeof (permutationsobject ), /* tp_basicsize */
3574- 0 , /* tp_itemsize */
3575- /* methods */
3576- (destructor )permutations_dealloc , /* tp_dealloc */
3577- 0 , /* tp_vectorcall_offset */
3578- 0 , /* tp_getattr */
3579- 0 , /* tp_setattr */
3580- 0 , /* tp_as_async */
3581- 0 , /* tp_repr */
3582- 0 , /* tp_as_number */
3583- 0 , /* tp_as_sequence */
3584- 0 , /* tp_as_mapping */
3585- 0 , /* tp_hash */
3586- 0 , /* tp_call */
3587- 0 , /* tp_str */
3588- PyObject_GenericGetAttr , /* tp_getattro */
3589- 0 , /* tp_setattro */
3590- 0 , /* tp_as_buffer */
3591- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3592- Py_TPFLAGS_BASETYPE , /* tp_flags */
3593- itertools_permutations__doc__ , /* tp_doc */
3594- (traverseproc )permutations_traverse ,/* tp_traverse */
3595- 0 , /* tp_clear */
3596- 0 , /* tp_richcompare */
3597- 0 , /* tp_weaklistoffset */
3598- PyObject_SelfIter , /* tp_iter */
3599- (iternextfunc )permutations_next , /* tp_iternext */
3600- permuations_methods , /* tp_methods */
3601- 0 , /* tp_members */
3602- 0 , /* tp_getset */
3603- 0 , /* tp_base */
3604- 0 , /* tp_dict */
3605- 0 , /* tp_descr_get */
3606- 0 , /* tp_descr_set */
3607- 0 , /* tp_dictoffset */
3608- 0 , /* tp_init */
3609- 0 , /* tp_alloc */
3610- itertools_permutations , /* tp_new */
3611- PyObject_GC_Del , /* tp_free */
3573+ static PyType_Slot permutations_slots [] = {
3574+ {Py_tp_dealloc , permutations_dealloc },
3575+ {Py_tp_getattro , PyObject_GenericGetAttr },
3576+ {Py_tp_doc , (void * )itertools_permutations__doc__ },
3577+ {Py_tp_traverse , permutations_traverse },
3578+ {Py_tp_iter , PyObject_SelfIter },
3579+ {Py_tp_iternext , permutations_next },
3580+ {Py_tp_methods , permuations_methods },
3581+ {Py_tp_new , itertools_permutations },
3582+ {Py_tp_free , PyObject_GC_Del },
3583+ {0 , NULL },
3584+ };
3585+
3586+ static PyType_Spec permutations_spec = {
3587+ .name = "itertools.permutations" ,
3588+ .basicsize = sizeof (permutationsobject ),
3589+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
3590+ Py_TPFLAGS_IMMUTABLETYPE ),
3591+ .slots = permutations_slots ,
36123592};
36133593
36143594
@@ -4847,6 +4827,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
48474827 Py_VISIT (state -> dropwhile_type );
48484828 Py_VISIT (state -> groupby_type );
48494829 Py_VISIT (state -> _grouper_type );
4830+ Py_VISIT (state -> permutations_type );
48504831 Py_VISIT (state -> starmap_type );
48514832 Py_VISIT (state -> takewhile_type );
48524833 return 0 ;
@@ -4862,6 +4843,7 @@ itertoolsmodule_clear(PyObject *mod)
48624843 Py_CLEAR (state -> dropwhile_type );
48634844 Py_CLEAR (state -> groupby_type );
48644845 Py_CLEAR (state -> _grouper_type );
4846+ Py_CLEAR (state -> permutations_type );
48654847 Py_CLEAR (state -> starmap_type );
48664848 Py_CLEAR (state -> takewhile_type );
48674849 return 0 ;
@@ -4894,6 +4876,7 @@ itertoolsmodule_exec(PyObject *mod)
48944876 ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
48954877 ADD_TYPE (mod , state -> groupby_type , & groupby_spec );
48964878 ADD_TYPE (mod , state -> _grouper_type , & _grouper_spec );
4879+ ADD_TYPE (mod , state -> permutations_type , & permutations_spec );
48974880 ADD_TYPE (mod , state -> starmap_type , & starmap_spec );
48984881 ADD_TYPE (mod , state -> takewhile_type , & takewhile_spec );
48994882
@@ -4907,7 +4890,6 @@ itertoolsmodule_exec(PyObject *mod)
49074890 & count_type ,
49084891 & ziplongest_type ,
49094892 & pairwise_type ,
4910- & permutations_type ,
49114893 & product_type ,
49124894 & repeat_type ,
49134895 & tee_type ,
0 commit comments