diff Objects/moduleobject.c @ 20277:2983b54256c7 legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Fri, 05 Oct 2001 20:51:39 +0000
parents 3faabf54b8b8
children c4d9d8674506
line wrap: on
line diff
--- a/Objects/moduleobject.c	Fri Oct 05 20:43:09 2001 +0000
+++ b/Objects/moduleobject.c	Fri Oct 05 20:51:39 2001 +0000
@@ -151,7 +151,7 @@
 		_PyModule_Clear((PyObject *)m);
 		Py_DECREF(m->md_dict);
 	}
-	PyObject_GC_Del(m);
+	m->ob_type->tp_free((PyObject *)m);
 }
 
 static PyObject *
@@ -225,4 +225,5 @@
 	(initproc)module_init,			/* tp_init */
 	PyType_GenericAlloc,			/* tp_alloc */
 	PyType_GenericNew,			/* tp_new */
+	_PyObject_GC_Del,			/* tp_free */
 };