On Sat, 19 Jan 2019 13:28:06 +1300 Greg Ewing <greg.ewing at 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4