Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47edb4b

Browse files
committed
Remove unnecessary GC support. Sets cannot have cycles.
1 parent 59efe36 commit 47edb4b

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

Objects/setobject.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,12 @@ frozenset_dict_wrapper(PyObject *d)
114114
static void
115115
set_dealloc(PySetObject *so)
116116
{
117-
PyObject_GC_UnTrack(so);
118117
if (so->weakreflist != NULL)
119118
PyObject_ClearWeakRefs((PyObject *) so);
120119
Py_XDECREF(so->data);
121120
so->ob_type->tp_free(so);
122121
}
123122

124-
static int
125-
set_traverse(PySetObject *so, visitproc visit, void *arg)
126-
{
127-
if (so->data)
128-
return visit(so->data, arg);
129-
return 0;
130-
}
131-
132123
static PyObject *
133124
set_iter(PySetObject *so)
134125
{
@@ -1017,11 +1008,11 @@ PyTypeObject PySet_Type = {
10171008
PyObject_GenericGetAttr, /* tp_getattro */
10181009
0, /* tp_setattro */
10191010
0, /* tp_as_buffer */
1020-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES |
1011+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
10211012
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */
10221013
set_doc, /* tp_doc */
1023-
(traverseproc)set_traverse, /* tp_traverse */
1024-
(inquiry)set_tp_clear, /* tp_clear */
1014+
0, /* tp_traverse */
1015+
0, /* tp_clear */
10251016
(richcmpfunc)set_richcompare, /* tp_richcompare */
10261017
offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */
10271018
(getiterfunc)set_iter, /* tp_iter */
@@ -1037,7 +1028,7 @@ PyTypeObject PySet_Type = {
10371028
(initproc)set_init, /* tp_init */
10381029
PyType_GenericAlloc, /* tp_alloc */
10391030
set_new, /* tp_new */
1040-
PyObject_GC_Del, /* tp_free */
1031+
PyObject_Del, /* tp_free */
10411032
};
10421033

10431034
/* frozenset object ********************************************************/
@@ -1112,10 +1103,10 @@ PyTypeObject PyFrozenSet_Type = {
11121103
PyObject_GenericGetAttr, /* tp_getattro */
11131104
0, /* tp_setattro */
11141105
0, /* tp_as_buffer */
1115-
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES |
1106+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
11161107
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */
11171108
frozenset_doc, /* tp_doc */
1118-
(traverseproc)set_traverse, /* tp_traverse */
1109+
0, /* tp_traverse */
11191110
0, /* tp_clear */
11201111
(richcmpfunc)set_richcompare, /* tp_richcompare */
11211112
offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */
@@ -1132,5 +1123,5 @@ PyTypeObject PyFrozenSet_Type = {
11321123
0, /* tp_init */
11331124
PyType_GenericAlloc, /* tp_alloc */
11341125
frozenset_new, /* tp_new */
1135-
PyObject_GC_Del, /* tp_free */
1126+
PyObject_Del, /* tp_free */
11361127
};

0 commit comments

Comments
 (0)