From 9475a2310d9cdec4b4c36dee8bf30c72605ae928 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 5 Oct 2001 20:51:39 +0000 Subject: 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. --- Objects/complexobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Objects/complexobject.c') diff --git a/Objects/complexobject.c b/Objects/complexobject.c index ee0ede4fc5..675d5b512a 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -265,7 +265,7 @@ PyComplex_AsCComplex(PyObject *op) static void complex_dealloc(PyObject *op) { - PyObject_DEL(op); + op->ob_type->tp_free(op); } @@ -970,6 +970,7 @@ PyTypeObject PyComplex_Type = { 0, /* tp_init */ 0, /* tp_alloc */ complex_new, /* tp_new */ + _PyObject_Del, /* tp_free */ }; #endif -- cgit v1.2.1