12
12
13
13
typedef struct {
14
14
PyTypeObject * cycle_type ;
15
+ PyTypeObject * dropwhile_type ;
15
16
PyTypeObject * groupby_type ;
16
17
PyTypeObject * _grouper_type ;
17
18
} itertools_state ;
@@ -42,7 +43,7 @@ class itertools.teedataobject "teedataobject *" "&teedataobject_type"
42
43
class itertools._tee "teeobject *" "&tee_type"
43
44
class itertools.batched "batchedobject *" "&batched_type"
44
45
class itertools.cycle "cycleobject *" "clinic_state()->cycle_type"
45
- class itertools.dropwhile "dropwhileobject *" "& dropwhile_type"
46
+ class itertools.dropwhile "dropwhileobject *" "clinic_state()-> dropwhile_type"
46
47
class itertools.takewhile "takewhileobject *" "&takewhile_type"
47
48
class itertools.starmap "starmapobject *" "&starmap_type"
48
49
class itertools.chain "chainobject *" "&chain_type"
@@ -55,12 +56,11 @@ class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
55
56
class itertools.count "countobject *" "&count_type"
56
57
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
57
58
[clinic start generated code]*/
58
- /*[clinic end generated code: output=da39a3ee5e6b4b0d input=b73cdca8e1fddfb5 ]*/
59
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=ef6f5c44c6837d9e ]*/
59
60
60
61
static PyTypeObject teedataobject_type ;
61
62
static PyTypeObject tee_type ;
62
63
static PyTypeObject batched_type ;
63
- static PyTypeObject dropwhile_type ;
64
64
static PyTypeObject takewhile_type ;
65
65
static PyTypeObject starmap_type ;
66
66
static PyTypeObject combinations_type ;
@@ -1441,15 +1441,18 @@ itertools_dropwhile_impl(PyTypeObject *type, PyObject *func, PyObject *seq)
1441
1441
static void
1442
1442
dropwhile_dealloc (dropwhileobject * lz )
1443
1443
{
1444
+ PyTypeObject * tp = Py_TYPE (lz );
1444
1445
PyObject_GC_UnTrack (lz );
1445
1446
Py_XDECREF (lz -> func );
1446
1447
Py_XDECREF (lz -> it );
1447
- Py_TYPE (lz )-> tp_free (lz );
1448
+ tp -> tp_free (lz );
1449
+ Py_DECREF (tp );
1448
1450
}
1449
1451
1450
1452
static int
1451
1453
dropwhile_traverse (dropwhileobject * lz , visitproc visit , void * arg )
1452
1454
{
1455
+ Py_VISIT (Py_TYPE (lz ));
1453
1456
Py_VISIT (lz -> it );
1454
1457
Py_VISIT (lz -> func );
1455
1458
return 0 ;
@@ -1512,48 +1515,25 @@ static PyMethodDef dropwhile_methods[] = {
1512
1515
{NULL , NULL } /* sentinel */
1513
1516
};
1514
1517
1515
- static PyTypeObject dropwhile_type = {
1516
- PyVarObject_HEAD_INIT (NULL , 0 )
1517
- "itertools.dropwhile" , /* tp_name */
1518
- sizeof (dropwhileobject ), /* tp_basicsize */
1519
- 0 , /* tp_itemsize */
1520
- /* methods */
1521
- (destructor )dropwhile_dealloc , /* tp_dealloc */
1522
- 0 , /* tp_vectorcall_offset */
1523
- 0 , /* tp_getattr */
1524
- 0 , /* tp_setattr */
1525
- 0 , /* tp_as_async */
1526
- 0 , /* tp_repr */
1527
- 0 , /* tp_as_number */
1528
- 0 , /* tp_as_sequence */
1529
- 0 , /* tp_as_mapping */
1530
- 0 , /* tp_hash */
1531
- 0 , /* tp_call */
1532
- 0 , /* tp_str */
1533
- PyObject_GenericGetAttr , /* tp_getattro */
1534
- 0 , /* tp_setattro */
1535
- 0 , /* tp_as_buffer */
1536
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1537
- Py_TPFLAGS_BASETYPE , /* tp_flags */
1538
- itertools_dropwhile__doc__ , /* tp_doc */
1539
- (traverseproc )dropwhile_traverse , /* tp_traverse */
1540
- 0 , /* tp_clear */
1541
- 0 , /* tp_richcompare */
1542
- 0 , /* tp_weaklistoffset */
1543
- PyObject_SelfIter , /* tp_iter */
1544
- (iternextfunc )dropwhile_next , /* tp_iternext */
1545
- dropwhile_methods , /* tp_methods */
1546
- 0 , /* tp_members */
1547
- 0 , /* tp_getset */
1548
- 0 , /* tp_base */
1549
- 0 , /* tp_dict */
1550
- 0 , /* tp_descr_get */
1551
- 0 , /* tp_descr_set */
1552
- 0 , /* tp_dictoffset */
1553
- 0 , /* tp_init */
1554
- 0 , /* tp_alloc */
1555
- itertools_dropwhile , /* tp_new */
1556
- PyObject_GC_Del , /* tp_free */
1518
+ static PyType_Slot dropwhile_slots [] = {
1519
+ {Py_tp_dealloc , dropwhile_dealloc },
1520
+ {Py_tp_getattro , PyObject_GenericGetAttr },
1521
+ {Py_tp_doc , (void * )itertools_dropwhile__doc__ },
1522
+ {Py_tp_traverse , dropwhile_traverse },
1523
+ {Py_tp_iter , PyObject_SelfIter },
1524
+ {Py_tp_iternext , dropwhile_next },
1525
+ {Py_tp_methods , dropwhile_methods },
1526
+ {Py_tp_new , itertools_dropwhile },
1527
+ {Py_tp_free , PyObject_GC_Del },
1528
+ {0 , NULL },
1529
+ };
1530
+
1531
+ static PyType_Spec dropwhile_spec = {
1532
+ .name = "itertools.dropwhile" ,
1533
+ .basicsize = sizeof (dropwhileobject ),
1534
+ .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE |
1535
+ Py_TPFLAGS_IMMUTABLETYPE ),
1536
+ .slots = dropwhile_slots ,
1557
1537
};
1558
1538
1559
1539
@@ -4943,6 +4923,7 @@ itertoolsmodule_traverse(PyObject *mod, visitproc visit, void *arg)
4943
4923
{
4944
4924
itertools_state * state = get_module_state (mod );
4945
4925
Py_VISIT (state -> cycle_type );
4926
+ Py_VISIT (state -> dropwhile_type );
4946
4927
Py_VISIT (state -> groupby_type );
4947
4928
Py_VISIT (state -> _grouper_type );
4948
4929
return 0 ;
@@ -4953,6 +4934,7 @@ itertoolsmodule_clear(PyObject *mod)
4953
4934
{
4954
4935
itertools_state * state = get_module_state (mod );
4955
4936
Py_CLEAR (state -> cycle_type );
4937
+ Py_CLEAR (state -> dropwhile_type );
4956
4938
Py_CLEAR (state -> groupby_type );
4957
4939
Py_CLEAR (state -> _grouper_type );
4958
4940
return 0 ;
@@ -4980,6 +4962,7 @@ itertoolsmodule_exec(PyObject *mod)
4980
4962
{
4981
4963
itertools_state * state = get_module_state (mod );
4982
4964
ADD_TYPE (mod , state -> cycle_type , & cycle_spec );
4965
+ ADD_TYPE (mod , state -> dropwhile_type , & dropwhile_spec );
4983
4966
ADD_TYPE (mod , state -> groupby_type , & groupby_spec );
4984
4967
ADD_TYPE (mod , state -> _grouper_type , & _grouper_spec );
4985
4968
@@ -4988,7 +4971,6 @@ itertoolsmodule_exec(PyObject *mod)
4988
4971
& batched_type ,
4989
4972
& combinations_type ,
4990
4973
& cwr_type ,
4991
- & dropwhile_type ,
4992
4974
& takewhile_type ,
4993
4975
& islice_type ,
4994
4976
& starmap_type ,
0 commit comments