[Patches] New sys method to return total reference count in debug builds.

Greg Stein gstein@lyra.org
Wed, 7 Jun 2000 14:24:54 -0700


On Wed, Jun 07, 2000 at 09:11:53AM -0700, Trent Mick wrote:
> On Mon, Jun 05, 2000 at 09:18:30AM +1000, Mark Hammond wrote:
> > + #ifdef Py_TRACE_REFS
> > + static PyObject *
> > + sys_gettotalrefcount(PyObject *self, PyObject *args)
> > + {
> > + 	extern long _Py_RefTotal;
> > + 	if (!PyArg_ParseTuple(args, ":gettotalrefcount"))
> > + 		return NULL;
> > + 	return PyInt_FromLong((long) _Py_RefTotal);
> > + }
> 
> I would just drop the (long) cast. It is not necessary and just adds a
> potential truncation if _Py_RefTotal is ever changed to size_t or something
> like that.

_Py_RefTotal is a count... it has nothing to do with sizes. I can't imagine
that it would be changed to a size_t (and I'd say it *shouldn't*).

I'm with you, though: dunno why the cast is in there.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/