[Python-bugs-list] [ python-Feature Requests-515073 ] subtypable weak references
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 16 Feb 2002 16:06:05 -0800
Feature Requests item #515073, was opened at 2002-02-08 16:50
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=515073&group_id=5470
Category: Type/class unification
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Abrahams (david_abrahams)
Assigned to: Nobody/Anonymous (nobody)
Summary: subtypable weak references
Initial Comment:
I want to be able to create a subtype of weakref.
Motivation: I use a trick to non-intrusively keep one
Python object (ward) alive as long as another one
(custodian) is: I build a weak reference to the
custodian whose kill function object holds a reference
to the ward. I "leak" the weakref, but the function
decrements its refcount so it will eventually die.
This scheme costs an extra allocation for the function
object, and because there is a function object at all,
there's no opportunity to re-use the weakref (please
document this part of the re-use behavior, BTW!)
I also want the re-use algorithm to check for object
and type equality so that I can avoid creating
multiple such references.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2002-02-16 16:06
Message:
Logged In: YES
user_id=21627
This is what the WeakKeyDictionary is for: use the custodian
as the key, and the ward as the value.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=515073&group_id=5470