[Python-Dev] survey of extension module memory managment
Fredrik Lundh
fredrik@pythonware.com
2002年3月19日 08:43:29 +0100
Neil Schemenauer wrote:
> I randomly grabbed a bunch of extension modules by searching the
> python.org topic guides and by using Parnassus. I looked at 20
> different packages. 12 of them implemented an extension type. 12 of
> them use the memory management API incorrectly and will break if
> pymalloc is enabled. That's worse than I thought.
$ more Python-1.5.2/Objects/xxobject.c
...
static xxobject *
newxxobject(arg)
PyObject *arg;
{
xxobject *xp;
xp = PyObject_NEW(xxobject, &Xxtype);
if (xp == NULL)
return NULL;
xp->x_attr = NULL;
return xp;
}
/* Xx methods */
static void
xx_dealloc(xp)
xxobject *xp;
{
Py_XDECREF(xp->x_attr);
PyMem_DEL(xp);
}
...
it looked like this between 1994 and May 2000.
and as noted elsewhere, PyObject_DEL, PyObject_New, and
PyObject_Del don't exist in older versions.
</F>