[Patches] [ python-Patches-983019 ] Making weakref.ref subclassable

SourceForge.net noreply at sourceforge.net
Fri Jul 2 12:08:18 EDT 2004


Patches item #983019, was opened at 2004-06-30 17:04
Message generated for change (Comment added) made by fdrake
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=983019&group_id=5470

Category: Core (C code)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: Fred L. Drake, Jr. (fdrake)
Assigned to: Nobody/Anonymous (nobody)
Summary: Making weakref.ref subclassable

Initial Comment:
This patch makes weak references subclassable.  This
includes the following changes:

- weakref.ref and weakref.ReferenceType will become
aliases for each other

- weakref.ref will be a modern, new-style class with
proper __new__ and __init__ methods

- weakref.WeakValueDictionary will have a lighter
memory footprint, using a new weakref.ref subclass to
associate the key with the value, allowing us to have
only a single object of overhead for each dictionary
entry (currently, there are 3 objects of overhead per
entry: a weakref to the value, a weakref to the
dictionary, and a function object used as a weakref
callback; the weakref to the dictionary could be
avoided without this change)

- a new macro, PyWeakref_CheckRefExact(), will be added

- PyWeakref_CheckRef() will check for subclasses of
weakref.ref

- the cyclic garbage detector will be affected by the
change to PyWeakref_CheckRef(); it will potentially
call issubtype() for objects in the unreachable list
that do not have finalizers (in the
move_troublemakers() function).  This should only
happen for weakref objects which are not of one of the
"standard" three types (ref, proxy, and callable
proxy).  For debug builds, it will also affect
assertions in the clear_weakerfs() and
release_weakrefs() functions.

The change to the  cyclic garbage detector probably
carries the most risk, and that only because the
potential for a performance penalty.  Running the Zope
3 test suite did not show any clear change in
performance, and a key subsystem in Zope
(zope.interface) uses weakrefs extensively.


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

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2004-07-02 12:08

Message:
Logged In: YES 
user_id=3066

Added LaTeX documentation as a separate patch.

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

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



More information about the Patches mailing list