Getting the reference count

Alex cut_me_out at hotmail.com
Sun Aug 27 16:42:53 EDT 2000


> I'm sure there must be a better way than messing about importing
> modules and deferencing attributes.  Presumably the reference count is
> stored inside the PyObject struct?

Here is the code for getrefcount.  What would you like to do that it's
not doing already?

static PyObject *
sys_getrefcount(PyObject *self, PyObject *args)
{
	PyObject *arg;
	if (!PyArg_ParseTuple(args, "O:getrefcount", &arg))
		return NULL;
	return PyInt_FromLong(arg->ob_refcnt);
}

Alex.

-- 
I'm not an outlier; I just haven't found my distribution yet.  
--- Ronan Conroy

To succeed in the world it is not enough to be stupid; you must also be
well-mannered. -- Voltaire




More information about the Python-list mailing list