[Python-Dev] Re: C new-style classes and GC
Jeremy Hylton
jeremy@zope.com
16 May 2003 15:42:40 -0400
I'm willing to believe there is a new and better way, but I don't think
I know what it is. How do we change this code, written using the old
PyObject_GC_New() to do things the new way?
Jeremy
PyObject *
PyDict_New(void)
{
register dictobject *mp;
if (dummy == NULL) { /* Auto-initialize dummy */
dummy = PyString_FromString("<dummy key>");
if (dummy == NULL)
return NULL;
#ifdef SHOW_CONVERSION_COUNTS
Py_AtExit(show_counts);
#endif
}
mp = PyObject_GC_New(dictobject, &PyDict_Type);
if (mp == NULL)
return NULL;
EMPTY_TO_MINSIZE(mp);
mp->ma_lookup = lookdict_string;
#ifdef SHOW_CONVERSION_COUNTS
++created;
#endif
_PyObject_GC_TRACK(mp);
return (PyObject *)mp;
}