@@ -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 ;
@@ -3343,12 +3343,14 @@ itertools_permutations_impl(PyTypeObject *type, PyObject *iterable,
3343
3343
static void
3344
3344
permutations_dealloc (permutationsobject * po )
3345
3345
{
3346
+ PyTypeObject * tp = Py_TYPE (po );
3346
3347
PyObject_GC_UnTrack (po );
3347
3348
Py_XDECREF (po -> pool );
3348
3349
Py_XDECREF (po -> result );
3349
3350
PyMem_Free (po -> indices );
3350
3351
PyMem_Free (po -> cycles );
3351
- Py_TYPE (po )-> tp_free (po );
3352
+ tp -> tp_free (po );
3353
+ Py_DECREF (tp );
3352
3354
}
3353
3355
3354
3356
static PyObject *
@@ -3363,6 +3365,7 @@ permutations_sizeof(permutationsobject *po, void *unused)
3363
3365
static int
3364
3366
permutations_traverse (permutationsobject * po , visitproc visit , void * arg )
3365
3367
{
3368
+ Py_VISIT (Py_TYPE (po ));
3366
3369
Py_VISIT (po -> pool );
3367
3370
Py_VISIT (po -> result );
3368
3371
return 0 ;
@@ -3568,48 +3571,25 @@ static PyMethodDef permuations_methods[] = {
3568
3571
{NULL , NULL } /* sentinel */
3569
3572
};
3570
3573
3571
- static PyTypeObject permutations_type = {
3572
- PyVarObject_HEAD_INIT (NULL , 0 )
3573
- "itertools.permutations" , /* tp_name */
3574
- sizeof (permutationsobject ), /* tp_basicsize */
3575
- 0 , /* tp_itemsize */
3576
- /* methods */
3577
- (destructor )permutations_dealloc , /* tp_dealloc */
3578
- 0 , /* tp_vectorcall_offset */
3579
- 0 , /* tp_getattr */
3580
- 0 , /* tp_setattr */
3581
- 0 , /* tp_as_async */
3582
- 0 , /* tp_repr */
3583
- 0 , /* tp_as_number */
3584
- 0 , /* tp_as_sequence */
3585
- 0 , /* tp_as_mapping */
3586
- 0 , /* tp_hash */
3587
- 0 , /* tp_call */
3588
- 0 , /* tp_str */
3589
- PyObject_GenericGetAttr , /* tp_getattro */
3590
- 0 , /* tp_setattro */
3591
- 0 , /* tp_as_buffer */
3592
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3593
- Py_TPFLAGS_BASETYPE , /* tp_flags */
3594
- itertools_permutations__doc__ , /* tp_doc */
3595
- (traverseproc )permutations_traverse ,/* tp_traverse */
3596
- 0 , /* tp_clear */
3597
- 0 , /* tp_richcompare */
3598
- 0 , /* tp_weaklistoffset */
3599
- PyObject_SelfIter , /* tp_iter */
3600
- (iternextfunc )permutations_next , /* tp_iternext */
3601
- permuations_methods , /* tp_methods */
3602
- 0 , /* tp_members */
3603
- 0 , /* tp_getset */
3604
- 0 , /* tp_base */
3605
- 0 , /* tp_dict */
3606
- 0 , /* tp_descr_get */
3607
- 0 , /* tp_descr_set */
3608
- 0 , /* tp_dictoffset */
3609
- 0 , /* tp_init */
3610
- 0 , /* tp_alloc */
3611
- itertools_permutations , /* tp_new */
3612
- PyObject_GC_Del , /* tp_free */
3574
+ static PyType_Slot permutations_slots [] = {
3575
+ {Py_tp_dealloc , permutations_dealloc },
3576
+ {Py_tp_getattro , PyObject_GenericGetAttr },
3577
+ {Py_tp_doc , (void * )itertools_permutations__doc__ },
3578
+ {Py_tp_traverse , permutations_traverse },
3579
+ {Py_tp_iter , PyObject_SelfIter },
3580
+ {Py_tp_iternext , permutations_next },
3581
+ {Py_tp_methods , permuations_methods },
3582
+ {Py_tp_new , itertools_permutations },
3583
+ {Py_tp_free , PyObject_GC_Del },
3584
+ {0 , NULL },
3585
+ };
3586
+
3587
+ static PyType_Spec permutations_spec = {
3588
+ .name = "itertools.permutations" ,
3589
+ .basicsize = sizeof (permutationsobject ),
3590
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
3591
+ Py_TPFLAGS_IMMUTABLETYPE ),
3592
+ .slots = permutations_slots ,
3613
3593
};
3614
3594
3615
3595
@@ -4848,6 +4828,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4848
4828
Py_VISIT (state -> dropwhile_type );
4849
4829
Py_VISIT (state -> groupby_type );
4850
4830
Py_VISIT (state -> _grouper_type );
4831
+ Py_VISIT (state -> permutations_type );
4851
4832
Py_VISIT (state -> starmap_type );
4852
4833
Py_VISIT (state -> takewhile_type );
4853
4834
return 0 ;
@@ -4863,6 +4844,7 @@ itertoolsmodule_clear(PyObject *mod)
4863
4844
Py_CLEAR (state -> dropwhile_type );
4864
4845
Py_CLEAR (state -> groupby_type );
4865
4846
Py_CLEAR (state -> _grouper_type );
4847
+ Py_CLEAR (state -> permutations_type );
4866
4848
Py_CLEAR (state -> starmap_type );
4867
4849
Py_CLEAR (state -> takewhile_type );
4868
4850
return 0 ;
@@ -4895,6 +4877,7 @@ itertoolsmodule_exec(PyObject *mod)
4895
4877
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
4896
4878
ADD_TYPE (mod , state -> groupby_type , & groupby_spec );
4897
4879
ADD_TYPE (mod , state -> _grouper_type , & _grouper_spec );
4880
+ ADD_TYPE (mod , state -> permutations_type , & permutations_spec );
4898
4881
ADD_TYPE (mod , state -> starmap_type , & starmap_spec );
4899
4882
ADD_TYPE (mod , state -> takewhile_type , & takewhile_spec );
4900
4883
@@ -4908,7 +4891,6 @@ itertoolsmodule_exec(PyObject *mod)
4908
4891
& count_type ,
4909
4892
& ziplongest_type ,
4910
4893
& pairwise_type ,
4911
- & permutations_type ,
4912
4894
& product_type ,
4913
4895
& repeat_type ,
4914
4896
& tee_type ,
0 commit comments