[Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?
Antoine Pitrou
solipsis at pitrou.net
Sat Jan 19 06:30:28 EST 2019
More information about the Python-Dev mailing list
Sat Jan 19 06:30:28 EST 2019
- Previous message (by thread): [Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?
- Next message (by thread): [Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message (by thread): [Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?
- Next message (by thread): [Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list