@@ -18,6 +18,7 @@ typedef struct {
18
18
PyTypeObject * dropwhile_type ;
19
19
PyTypeObject * groupby_type ;
20
20
PyTypeObject * _grouper_type ;
21
+ PyTypeObject * permutations_type ;
21
22
PyTypeObject * starmap_type ;
22
23
PyTypeObject * takewhile_type ;
23
24
} itertools_state ;
@@ -63,19 +64,18 @@ class itertools.starmap "starmapobject *" "clinic_state()->starmap_type"
63
64
class itertools.chain "chainobject *" "&chain_type"
64
65
class itertools.combinations "combinationsobject *" "clinic_state()->combinations_type"
65
66
class 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"
67
68
class itertools.accumulate "accumulateobject *" "&accumulate_type"
68
69
class itertools.compress "compressobject *" "&compress_type"
69
70
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
70
71
class itertools.count "countobject *" "&count_type"
71
72
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
72
73
[clinic start generated code]*/
73
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=d44fee9ebae461fb ]*/
74
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=1790ac655869a651 ]*/
74
75
75
76
static PyTypeObject teedataobject_type ;
76
77
static PyTypeObject tee_type ;
77
78
static PyTypeObject batched_type ;
78
- static PyTypeObject permutations_type ;
79
79
static PyTypeObject accumulate_type ;
80
80
static PyTypeObject compress_type ;
81
81
static PyTypeObject filterfalse_type ;
@@ -3356,12 +3356,14 @@ itertools_permutations_impl(PyTypeObject *type, PyObject *iterable,
3356
3356
static void
3357
3357
permutations_dealloc (permutationsobject * po )
3358
3358
{
3359
+ PyTypeObject * tp = Py_TYPE (po );
3359
3360
PyObject_GC_UnTrack (po );
3360
3361
Py_XDECREF (po -> pool );
3361
3362
Py_XDECREF (po -> result );
3362
3363
PyMem_Free (po -> indices );
3363
3364
PyMem_Free (po -> cycles );
3364
- Py_TYPE (po )-> tp_free (po );
3365
+ tp -> tp_free (po );
3366
+ Py_DECREF (tp );
3365
3367
}
3366
3368
3367
3369
static PyObject *
@@ -3376,6 +3378,7 @@ permutations_sizeof(permutationsobject *po, void *unused)
3376
3378
static int
3377
3379
permutations_traverse (permutationsobject * po , visitproc visit , void * arg )
3378
3380
{
3381
+ Py_VISIT (Py_TYPE (po ));
3379
3382
Py_VISIT (po -> pool );
3380
3383
Py_VISIT (po -> result );
3381
3384
return 0 ;
@@ -3581,48 +3584,25 @@ static PyMethodDef permuations_methods[] = {
3581
3584
{NULL , NULL } /* sentinel */
3582
3585
};
3583
3586
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 ,
3626
3606
};
3627
3607
3628
3608
@@ -4861,6 +4841,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4861
4841
Py_VISIT (state -> dropwhile_type );
4862
4842
Py_VISIT (state -> groupby_type );
4863
4843
Py_VISIT (state -> _grouper_type );
4844
+ Py_VISIT (state -> permutations_type );
4864
4845
Py_VISIT (state -> starmap_type );
4865
4846
Py_VISIT (state -> takewhile_type );
4866
4847
return 0 ;
@@ -4876,6 +4857,7 @@ itertoolsmodule_clear(PyObject *mod)
4876
4857
Py_CLEAR (state -> dropwhile_type );
4877
4858
Py_CLEAR (state -> groupby_type );
4878
4859
Py_CLEAR (state -> _grouper_type );
4860
+ Py_CLEAR (state -> permutations_type );
4879
4861
Py_CLEAR (state -> starmap_type );
4880
4862
Py_CLEAR (state -> takewhile_type );
4881
4863
return 0 ;
@@ -4908,6 +4890,7 @@ itertoolsmodule_exec(PyObject *mod)
4908
4890
ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
4909
4891
ADD_TYPE (mod , state -> groupby_type , & groupby_spec );
4910
4892
ADD_TYPE (mod , state -> _grouper_type , & _grouper_spec );
4893
+ ADD_TYPE (mod , state -> permutations_type , & permutations_spec );
4911
4894
ADD_TYPE (mod , state -> starmap_type , & starmap_spec );
4912
4895
ADD_TYPE (mod , state -> takewhile_type , & takewhile_spec );
4913
4896
@@ -4921,7 +4904,6 @@ itertoolsmodule_exec(PyObject *mod)
4921
4904
& count_type ,
4922
4905
& ziplongest_type ,
4923
4906
& pairwise_type ,
4924
- & permutations_type ,
4925
4907
& product_type ,
4926
4908
& repeat_type ,
4927
4909
& tee_type ,
0 commit comments