@@ -17,6 +17,7 @@ typedef struct {
17
17
PyTypeObject * dropwhile_type ;
18
18
PyTypeObject * groupby_type ;
19
19
PyTypeObject * _grouper_type ;
20
+ PyTypeObject * permutations_type ;
20
21
PyTypeObject * starmap_type ;
21
22
PyTypeObject * takewhile_type ;
22
23
} itertools_state ;
@@ -53,19 +54,18 @@ class itertools.starmap "starmapobject *" "clinic_state()->starmap_type"
53
54
class itertools.chain "chainobject *" "&chain_type"
54
55
class itertools.combinations "combinationsobject *" "clinic_state()->combinations_type"
55
56
class 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"
57
58
class itertools.accumulate "accumulateobject *" "&accumulate_type"
58
59
class itertools.compress "compressobject *" "&compress_type"
59
60
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
60
61
class itertools.count "countobject *" "&count_type"
61
62
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
62
63
[clinic start generated code]*/
63
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=d44fee9ebae461fb ]*/
64
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=1790ac655869a651 ]*/
64
65
65
66
static PyTypeObject teedataobject_type ;
66
67
static PyTypeObject tee_type ;
67
68
static PyTypeObject batched_type ;
68
- static PyTypeObject permutations_type ;
69
69
static PyTypeObject accumulate_type ;
70
70
static PyTypeObject compress_type ;
71
71
static PyTypeObject filterfalse_type ;
@@ -3342,12 +3342,14 @@ itertools_permutations_impl(PyTypeObject *type, PyObject *iterable,
3342
3342
static void
3343
3343
permutations_dealloc (permutationsobject * po )
3344
3344
{
3345
+ PyTypeObject * tp = Py_TYPE (po );
3345
3346
PyObject_GC_UnTrack (po );
3346
3347
Py_XDECREF (po -> pool );
3347
3348
Py_XDECREF (po -> result );
3348
3349
PyMem_Free (po -> indices );
3349
3350
PyMem_Free (po -> cycles );
3350
- Py_TYPE (po )-> tp_free (po );
3351
+ tp -> tp_free (po );
3352
+ Py_DECREF (tp );
3351
3353
}
3352
3354
3353
3355
static PyObject *
@@ -3362,6 +3364,7 @@ permutations_sizeof(permutationsobject *po, void *unused)
3362
3364
static int
3363
3365
permutations_traverse (permutationsobject * po , visitproc visit , void * arg )
3364
3366
{
3367
+ Py_VISIT (Py_TYPE (po ));
3365
3368
Py_VISIT (po -> pool );
3366
3369
Py_VISIT (po -> result );
3367
3370
return 0 ;
@@ -3567,48 +3570,25 @@ static PyMethodDef permuations_methods[] = {
3567
3570
{NULL , NULL } /* sentinel */
3568
3571
};
3569
3572
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 ,
3612
3592
};
3613
3593
3614
3594
@@ -4847,6 +4827,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4847
4827
Py_VISIT (state -> dropwhile_type );
4848
4828
Py_VISIT (state -> groupby_type );
4849
4829
Py_VISIT (state -> _grouper_type );
4830
+ Py_VISIT (state -> permutations_type );
4850
4831
Py_VISIT (state -> starmap_type );
4851
4832
Py_VISIT (state -> takewhile_type );
4852
4833
return 0 ;
@@ -4862,6 +4843,7 @@ itertoolsmodule_clear(PyObject *mod)
4862
4843
Py_CLEAR (state -> dropwhile_type );
4863
4844
Py_CLEAR (state -> groupby_type );
4864
4845
Py_CLEAR (state -> _grouper_type );
4846
+ Py_CLEAR (state -> permutations_type );
4865
4847
Py_CLEAR (state -> starmap_type );
4866
4848
Py_CLEAR (state -> takewhile_type );
4867
4849
return 0 ;
@@ -4894,6 +4876,7 @@ itertoolsmodule_exec(PyObject *mod)
4894
4876
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
4895
4877
ADD_TYPE (mod , state -> groupby_type , & groupby_spec );
4896
4878
ADD_TYPE (mod , state -> _grouper_type , & _grouper_spec );
4879
+ ADD_TYPE (mod , state -> permutations_type , & permutations_spec );
4897
4880
ADD_TYPE (mod , state -> starmap_type , & starmap_spec );
4898
4881
ADD_TYPE (mod , state -> takewhile_type , & takewhile_spec );
4899
4882
@@ -4907,7 +4890,6 @@ itertoolsmodule_exec(PyObject *mod)
4907
4890
& count_type ,
4908
4891
& ziplongest_type ,
4909
4892
& pairwise_type ,
4910
- & permutations_type ,
4911
4893
& product_type ,
4912
4894
& repeat_type ,
4913
4895
& tee_type ,
0 commit comments