title: What is the use case for python's weakref if it is not guaranteed to be dead when the object's reference count reaches zero?
body: <p>One of the use cases python's docs propose for weak references is to keep references to large cached objects without increasing their reference count, <a href="https://docs.python.org/3/library/weakref.html" rel="nofollow">thus not preventing them from being garbage collected when their time  comes</a>.</p>
  
  <p>However, garbage collection is not guaranteed to happen immediately after an object's refcount reaches zero, and a weakref is only invalidated when the GC collects its target. So essentially one can be left holding a valid (not dead) weakref to an invalid object - <a href="https://bitbucket.org/pypy/pypy/issues/1269/weakrefweakset-does-not-work-correctly" rel="nofollow">PyPy's broken WeakSet is one example of such a scenario</a>. </p>
  
  <p>So assuming an adversarialy-minded garbage collector, is there a scenario (apart from finalizers) where weak references provide deterministic and useful behavior to the user?</p>