weakref.WeakKeyDictionary

class weakref.WeakKeyDictionary(dict=None)[source]

Mapping class that references keys weakly.

Entries in the dictionary will be discarded when there is no longer a strong reference to the key. This can be used to associate additional data with an object owned by other parts of an application without adding attributes to those objects. This can be especially useful with objects that override attribute accesses.

Methods

__cmp__(dict)
__contains__(key)
__copy__()
__deepcopy__(memo)
__delitem__(key)
__getitem__(key)
__init__([dict])
__iter__()
__len__()
__repr__()
__setitem__(key, value)
_commit_removals()
clear()
copy()
fromkeys(iterable[, value])
get(key[, default])
has_key(key)
items()
iteritems()
iterkeyrefs() Return an iterator that yields the weak references to the keys.
iterkeys()
itervalues()
keyrefs() Return a list of weak references to the keys.
keys()
pop(key, *args)
popitem()
setdefault(key[, default])
update([dict])
values()