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

noreply@sourceforge.net noreply@sourceforge.net
Sun, 19 Aug 2001 12:59:28 -0700


Patches item #421893, was opened at 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: Out of Date
Priority: 5
Submitted By: Neil Schemenauer (nascheme)
>Assigned to: Guido van Rossum (gvanrossum)
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: Neil Schemenauer (nascheme)
Date: 2001-08-19 12:59

Message:
Logged In: YES 
user_id=35752

I've brought the patch up to date.  I'm not sure if we
really need this patch.  The current approach works okay.
I think this patch improves things since more
details about the GC implementation are hidden.  This would
give us more freedom to change the implementation in the
future.  Also, I think the patch makes it easier for
extension types to support GC.  The patch is somewhat
backwards compatible now.  Types that use the old interface
will still compile but will not be GCed.


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

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

Message:
Logged In: YES 
user_id=6380

Neil, do we still need this?
I've marked it out-of-date because I'm sure that it won't
apply cleanly any more.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-06-16 09:25

Message:
Logged In: YES 
user_id=6380

I think I know a way to fix the incompatibility, by
switching to a different flag bit.  I'll try to work this
into the descr-branch code.

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

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