[Patches] [ python-Patches-421893 ] Cleanup GC API

noreply@sourceforge.net noreply@sourceforge.net
Mon, 04 Jun 2001 10:13:25 -0700


Patches item #421893, was updated on 2001-05-06 14:42
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=421893&group_id=5470

Category: core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Neil Schemenauer (nascheme)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Cleanup GC API

Initial Comment:
This patch adds three new APIs:

	PyObject_GC_New
	PyObject_GC_NewVar
	PyObject_GC_Resize
	PyObject_GC_Del

and renames PyObject_GC_Init and PyObject_GC_Fini to:

	PyObject_GC_Track
	PyObject_GC_Ignore

respectively.  Objects that wish to be tracked by the
collector must use these new APIs.  Many more details
about the GC implementation are hidden inside
gcmodule.c.  There seems to be no change in
performance.

Note that PyObject_GC_{New,NewVar} automatically adds
the object to the GC lists.  There is no need to
call PyObject_GC_Track.  PyObject_GC_Del automatically
removes the object from the GC list but usually you
want to call PyObject_GC_Ignore yourself (DECREFs can
end up running arbitrary code).

It should be more difficult to corrupt the GC linked
lists now.  Also, you can now call PyObject_GC_Ignore
on objects that you know will not create RCs. The
_weakref module does this.  Previously, every object
that had the GC type flag set and could be found by
using tp_traverse had to be in a GC linked list.


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

>Comment By: Martin v. Löwis (loewis)
Date: 2001-06-04 10:13

Message:
Logged In: YES 
user_id=21627

I have two problems with this patch:
1. It comes with no documentation.
2. It breaks existing third-party modules which use the 
   GC API as defined in Python 2.
Consequently, I recommend rejection of the patch in its 
current form.


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

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