Guido van Rossum discourseth: > [MAL] > > These already exist... http://www.handshake.de/~dieter/weakdict.html > > > > mx.Proxy also has an implementation which support weak references. > > Thanks. For Fred to read... He may want to also see my http://www.hyperreal.org/~est/python/weak (also registered in the vaults), an implementation of weak dicts and proxy maps that doesn't require the contained objects to be subclassed. It even has documentation in standard format (!) including some words about motivation. One simple implementation approach to make it work for all objects might be to have: int PyObject_PushWeakHandler(PyObject *o, void (*handler)(PyObject *o, PyObject *data), PyObject *data); When an object is deallocated all its handlers would be called on the object and the data that was registered with the handler. I believe this would make weak dicts a very simple extension module. With this approach I suspect DATA should be incref'd by the call to PyObject_PushWeakHandler() and decref'd after the associated handler is called. Best, Eric
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