Python 2.0
Stidolph, David
stidolph at origin.ea.com
Tue Jun 1 11:31:16 EDT 1999
Py_TRACE_REFS seems to be defined if Py_DEBUG is defined.
I cannot find a "getobjects" or any other similar function in the source
code or docs. I am using the Win32 version 1.5.2.
Any help would be appreciated,
David Stidolph.
-----Original Message-----
From: Michael Hudson [mailto:mwh21 at cam.ac.uk]
Sent: Tuesday, June 01, 1999 4:55 AM
To: python-list at cwi.nl
Subject: Re: Python 2.0
"Stidolph, David" <stidolph at origin.ea.com> writes:
> >OK, I'll try to propose something constructive. Maybe we need an object
> >protocol, that would enumerate
> >all references held by an object ? Writing a portable GC would be then
> much
> >easier.
>
> Sounds good to me for debugging. A call that could return a list of
> everything that holds a reference to an object - that would be cool!
>
> list = GetReferences(object)
> print 'List of referencest to',object
> for item in list:
> print 'item:',item
>
> Anybody know of a current way to do this?
If you recompile Python with Py_TRACE_REFS defined, then the sys
module sprouts a "getobjects" function that returns a list of all
objects in existence. This could probably be used to implement
something like this. It would be veeeeery slow, I suspect.
I've never resorted to this approach, tending always to make cyclic
references go away be staring at them very, very hard.
I'm not sure this is at all what is being asked for, but it seems kind
of relavent.
Yours,
Michael
More information about the Python-list
mailing list