Skip to content

weakref

jasper-zanjani edited this page Aug 6, 2020 · 1 revision

Support weak references, that is, references to objects which return exceptions when that object has been garbage collected Create a weak reference to {object}

# A weak reference created using `ref` must be dereferenced 
r = weakref.ref(obj) 
r().method() 
r.method()          # will not work

# A weak reference created using `proxy` does not need to be dereferenced:
weakref.proxy(obj)

Clone this wiki locally