@@ -18,6 +18,7 @@ typedef struct {
1818    PyTypeObject  * dropwhile_type ;
1919    PyTypeObject  * groupby_type ;
2020    PyTypeObject  * _grouper_type ;
21+     PyTypeObject  * permutations_type ;
2122    PyTypeObject  * starmap_type ;
2223    PyTypeObject  * takewhile_type ;
2324} itertools_state ;
@@ -63,19 +64,18 @@ class itertools.starmap "starmapobject *" "clinic_state()->starmap_type"
6364class itertools.chain "chainobject *" "&chain_type" 
6465class itertools.combinations "combinationsobject *" "clinic_state()->combinations_type" 
6566class itertools.combinations_with_replacement "cwr_object *" "clinic_state()->cwr_type" 
66- class itertools.permutations "permutationsobject *" "& permutations_type" 
67+ class itertools.permutations "permutationsobject *" "clinic_state()-> permutations_type" 
6768class itertools.accumulate "accumulateobject *" "&accumulate_type" 
6869class itertools.compress "compressobject *" "&compress_type" 
6970class itertools.filterfalse "filterfalseobject *" "&filterfalse_type" 
7071class itertools.count "countobject *" "&count_type" 
7172class itertools.pairwise "pairwiseobject *" "&pairwise_type" 
7273[clinic start generated code]*/ 
73- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=d44fee9ebae461fb ]*/ 
74+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=1790ac655869a651 ]*/ 
7475
7576static  PyTypeObject  teedataobject_type ;
7677static  PyTypeObject  tee_type ;
7778static  PyTypeObject  batched_type ;
78- static  PyTypeObject  permutations_type ;
7979static  PyTypeObject  accumulate_type ;
8080static  PyTypeObject  compress_type ;
8181static  PyTypeObject  filterfalse_type ;
@@ -3356,12 +3356,14 @@ itertools_permutations_impl(PyTypeObject *type, PyObject *iterable,
33563356static  void 
33573357permutations_dealloc (permutationsobject  * po )
33583358{
3359+     PyTypeObject  * tp  =  Py_TYPE (po );
33593360    PyObject_GC_UnTrack (po );
33603361    Py_XDECREF (po -> pool );
33613362    Py_XDECREF (po -> result );
33623363    PyMem_Free (po -> indices );
33633364    PyMem_Free (po -> cycles );
3364-     Py_TYPE (po )-> tp_free (po );
3365+     tp -> tp_free (po );
3366+     Py_DECREF (tp );
33653367}
33663368
33673369static  PyObject  * 
@@ -3376,6 +3378,7 @@ permutations_sizeof(permutationsobject *po, void *unused)
33763378static  int 
33773379permutations_traverse (permutationsobject  * po , visitproc  visit , void  * arg )
33783380{
3381+     Py_VISIT (Py_TYPE (po ));
33793382    Py_VISIT (po -> pool );
33803383    Py_VISIT (po -> result );
33813384    return  0 ;
@@ -3581,48 +3584,25 @@ static PyMethodDef permuations_methods[] = {
35813584    {NULL ,              NULL }   /* sentinel */ 
35823585};
35833586
3584- static  PyTypeObject  permutations_type  =  {
3585-     PyVarObject_HEAD_INIT (NULL , 0 )
3586-     "itertools.permutations" ,           /* tp_name */ 
3587-     sizeof (permutationsobject ),         /* tp_basicsize */ 
3588-     0 ,                                  /* tp_itemsize */ 
3589-     /* methods */ 
3590-     (destructor )permutations_dealloc ,   /* tp_dealloc */ 
3591-     0 ,                                  /* tp_vectorcall_offset */ 
3592-     0 ,                                  /* tp_getattr */ 
3593-     0 ,                                  /* tp_setattr */ 
3594-     0 ,                                  /* tp_as_async */ 
3595-     0 ,                                  /* tp_repr */ 
3596-     0 ,                                  /* tp_as_number */ 
3597-     0 ,                                  /* tp_as_sequence */ 
3598-     0 ,                                  /* tp_as_mapping */ 
3599-     0 ,                                  /* tp_hash */ 
3600-     0 ,                                  /* tp_call */ 
3601-     0 ,                                  /* tp_str */ 
3602-     PyObject_GenericGetAttr ,            /* tp_getattro */ 
3603-     0 ,                                  /* tp_setattro */ 
3604-     0 ,                                  /* tp_as_buffer */ 
3605-     Py_TPFLAGS_DEFAULT  | Py_TPFLAGS_HAVE_GC  |
3606-         Py_TPFLAGS_BASETYPE ,            /* tp_flags */ 
3607-     itertools_permutations__doc__ ,      /* tp_doc */ 
3608-     (traverseproc )permutations_traverse ,/* tp_traverse */ 
3609-     0 ,                                  /* tp_clear */ 
3610-     0 ,                                  /* tp_richcompare */ 
3611-     0 ,                                  /* tp_weaklistoffset */ 
3612-     PyObject_SelfIter ,                  /* tp_iter */ 
3613-     (iternextfunc )permutations_next ,    /* tp_iternext */ 
3614-     permuations_methods ,                /* tp_methods */ 
3615-     0 ,                                  /* tp_members */ 
3616-     0 ,                                  /* tp_getset */ 
3617-     0 ,                                  /* tp_base */ 
3618-     0 ,                                  /* tp_dict */ 
3619-     0 ,                                  /* tp_descr_get */ 
3620-     0 ,                                  /* tp_descr_set */ 
3621-     0 ,                                  /* tp_dictoffset */ 
3622-     0 ,                                  /* tp_init */ 
3623-     0 ,                                  /* tp_alloc */ 
3624-     itertools_permutations ,             /* tp_new */ 
3625-     PyObject_GC_Del ,                    /* tp_free */ 
3587+ static  PyType_Slot  permutations_slots [] =  {
3588+     {Py_tp_dealloc , permutations_dealloc },
3589+     {Py_tp_getattro , PyObject_GenericGetAttr },
3590+     {Py_tp_doc , (void  * )itertools_permutations__doc__ },
3591+     {Py_tp_traverse , permutations_traverse },
3592+     {Py_tp_iter , PyObject_SelfIter },
3593+     {Py_tp_iternext , permutations_next },
3594+     {Py_tp_methods , permuations_methods },
3595+     {Py_tp_new , itertools_permutations },
3596+     {Py_tp_free , PyObject_GC_Del },
3597+     {0 , NULL },
3598+ };
3599+ 
3600+ static  PyType_Spec  permutations_spec  =  {
3601+     .name  =  "itertools.permutations" ,
3602+     .basicsize  =  sizeof (permutationsobject ),
3603+     .flags  =  (Py_TPFLAGS_DEFAULT  | Py_TPFLAGS_HAVE_GC  | Py_TPFLAGS_BASETYPE  |
3604+               Py_TPFLAGS_IMMUTABLETYPE ),
3605+     .slots  =  permutations_slots ,
36263606};
36273607
36283608
@@ -4861,6 +4841,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
48614841    Py_VISIT (state -> dropwhile_type );
48624842    Py_VISIT (state -> groupby_type );
48634843    Py_VISIT (state -> _grouper_type );
4844+     Py_VISIT (state -> permutations_type );
48644845    Py_VISIT (state -> starmap_type );
48654846    Py_VISIT (state -> takewhile_type );
48664847    return  0 ;
@@ -4876,6 +4857,7 @@ itertoolsmodule_clear(PyObject *mod)
48764857    Py_CLEAR (state -> dropwhile_type );
48774858    Py_CLEAR (state -> groupby_type );
48784859    Py_CLEAR (state -> _grouper_type );
4860+     Py_CLEAR (state -> permutations_type );
48794861    Py_CLEAR (state -> starmap_type );
48804862    Py_CLEAR (state -> takewhile_type );
48814863    return  0 ;
@@ -4908,6 +4890,7 @@ itertoolsmodule_exec(PyObject *mod)
49084890    ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
49094891    ADD_TYPE (mod , state -> groupby_type , & groupby_spec );
49104892    ADD_TYPE (mod , state -> _grouper_type , & _grouper_spec );
4893+     ADD_TYPE (mod , state -> permutations_type , & permutations_spec );
49114894    ADD_TYPE (mod , state -> starmap_type , & starmap_spec );
49124895    ADD_TYPE (mod , state -> takewhile_type , & takewhile_spec );
49134896
@@ -4921,7 +4904,6 @@ itertoolsmodule_exec(PyObject *mod)
49214904        & count_type ,
49224905        & ziplongest_type ,
49234906        & pairwise_type ,
4924-         & permutations_type ,
49254907        & product_type ,
49264908        & repeat_type ,
49274909        & tee_type ,
0 commit comments