On Sat, 19 Jan 2019 13:28:06 +1300
Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> Tim Peters wrote:
> 
> > The dict itself keeps the objects alive.  
> 
> Yes, but the idea of a cache is that you're free to flush
> things out of it to make room for something else without
> breaking anything.
> 
> It sounds like MRAB is using ids as weak references,
> without the assurance actual weak references give you
> that they become invalidated when the refefenced object
> goes away,

Hmm...  That sounds nonsensical to me. By construction, if you're able
to get a reference to an object in pure Python, then the object is
alive.

(by pure Python I'm excluding ctypes hacks or the exploitation of bugs
in the CPython object implementation)

By the way, you can also have a WeakValueDictionary where keys are ids
and values are the corresponding objects, if you need both identity
lookup and weak references.

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to