summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-05 20:51:39 (GMT)
committerGuido van Rossum <guido@python.org>2001-10-05 20:51:39 (GMT)
commit9475a2310d9cdec4b4c36dee8bf30c72605ae928 (patch)
tree54b58a165e7b91118dafaa54a00db24162abdff7 /Objects/fileobject.c
parentbe63884d5069901effb9c045bde43e732c969f71 (diff)
downloadcpython-9475a2310d9cdec4b4c36dee8bf30c72605ae928.zip
cpython-9475a2310d9cdec4b4c36dee8bf30c72605ae928.tar.gz
cpython-9475a2310d9cdec4b4c36dee8bf30c72605ae928.tar.bz2
Enable GC for new-style instances. This touches lots of files, since
many types were subclassable but had a xxx_dealloc function that called PyObject_DEL(self) directly instead of deferring to self->ob_type->tp_free(self). It is permissible to set tp_free in the type object directly to _PyObject_Del, for non-GC types, or to _PyObject_GC_Del, for GC types. Still, PyObject_DEL was a tad faster, so I'm fearing that our pystone rating is going down again. I'm not sure if doing something like void xxx_dealloc(PyObject *self) { if (PyXxxCheckExact(self)) PyObject_DEL(self); else self->ob_type->tp_free(self); } is any faster than always calling the else branch, so I haven't attempted that -- however those types whose own dealloc is fancier (int, float, unicode) do use this pattern.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index d330924..9a249aa 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -208,7 +208,7 @@ file_dealloc(PyFileObject *f)
}
Py_XDECREF(f->f_name);
Py_XDECREF(f->f_mode);
- PyObject_DEL(f);
+ f->ob_type->tp_free((PyObject *)f);
}
static PyObject *
@@ -1508,8 +1508,7 @@ PyTypeObject PyFile_Type = {
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT |
- Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
file_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
@@ -1528,6 +1527,7 @@ PyTypeObject PyFile_Type = {
(initproc)file_init, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */
file_new, /* tp_new */
+ _PyObject_Del, /* tp_free */
};
/* Interface for the 'soft space' between print items. */