[Patches] [ python-Patches-402925 ] Add new function gc.getreferents

noreply@sourceforge.net noreply@sourceforge.net
Thu, 09 Aug 2001 09:00:37 -0700


Patches item #402925, was opened at 2000-12-19 07:08
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=402925&group_id=5470

Category: core (C code)
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Martin v. Löwis (loewis)
Assigned to: Neil Schemenauer (nascheme)
Summary: Add new function gc.getreferents

Initial Comment:
 

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-09 09:00

Message:
Logged In: YES 
user_id=6380

Looks like Neil checked something like this in today.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2000-12-19 14:52

Message:
Even though the function does not find all references to an object, it does find all objects that have references to some object - at least if all container types participate in garbage collection (I expect that most extension types will know about GC sooner or later).
In particular, it finds containers that can't be found from pure Python, eg. containers that are stored only in a global variable of some C module. Even not being able to explain all references to some object gives a useful clue.

I agree that exposing traversal to Python is a useful feature, but that is completely different from that function - you'd also need to expose the generations lists (which this patch does access, but pure Python can't).

----------------------------------------------------------------------

Comment By: Neil Schemenauer (nascheme)
Date: 2000-12-19 11:25

Message:
I'm -0 on this patch. The function is not as useful as it seems.  The
garbage collector does not and most likely never will be able to track
down all references to an object (eg. an extension types could have a
reference to it).  If it could, we would be using a different
collection scheme like mark and sweep.

For debugging reference cycles like the RExec problem a pure Python
tool (similar to Cyclops) would work.  The tool just has
to know how to chase references in different kinds of
objects.  Perhaps exposing the GC's knowledge of this
would be more useful and general.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2000-12-19 07:13

Message:
This patch adds a new function gc.getreferents which traverses all collectable objects and returns a list of objects that refer to any of the parameters of gc.getreferents.
This will only find references visible to the gc; references in local variables of functions that are currently on the stack won't be found.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=402925&group_id=5470