Hi all.
I'm writing a module to proxy C++ objects into Python for a large C++
application. There are hundreds of thousands of C++ objects, some of
which are temporary while others are very long lived.
Currently every time one of these objects is accessed from Python, a
new myproxy instance is
Tom Whittock, 27.06.2011 12:48:
I'm writing a module to proxy C++ objects into Python for a large C++
application. There are hundreds of thousands of C++ objects, some of
which are temporary while others are very long lived.
Currently every time one of these objects is accessed from Python, a
Tom Whittock wrote:
Currently every time one of these objects is accessed from Python, a
new myproxy instance is created. So if I were to access the same
field of an object twice, I would receive two python objects proxying
the same underlying C++ object.
Perhaps you could use a
Hi Greg thanks for your quick reply.
Perhaps you could use a WeakValueDictionary to keep a mapping
from a C++ object address to its Python proxy.
Thank you, I'll implement this and see whether it works out. I'll
certainly be better off if it does. I was avoiding holding weak
references due to
Hi again.
Just to let you know that Greg's suggestion worked beautifully - I
guess my id idea was just me trying to make life hard for myself.
My concerns over the json modules usage of id seem unjustified, as
circular references are detected now that the weak reference
dictionary is in place.