[Python-Dev] Weak references: dereference notification

Gustavo J. A. M. Carneiro gjc at inescporto.pt
Wed Nov 9 12:40:25 CET 2005


 Hello,
 I have come across a situation where I find the current weak
references interface for extension types insufficient.
 Currently you only have a tp_weaklistoffset slot, pointing to a
PyObject with weak references. However, in my case[1] I _really_ need
to be notified when a weak reference is dereferenced. What happens now
is that, when you call a weakref object, a simple Py_INCREF is done on
the referenced object. It would be easy to implement a new slot to
contain a function that should be called when a weak reference is
dereferenced. Or, alternatively, a slot or class attribute that
indicates an alternative type that should be used to create weak
references: instead of the builtin weakref object, a subtype of it, so
you can override tp_call.
 Does this sounds acceptable?
 
 Regards.
[1] http://bugzilla.gnome.org/show_bug.cgi?id=320428
-- 
Gustavo J. A. M. Carneiro
<gjc at inescporto.pt> <gustavo at users.sourceforge.net>
The universe is always one step beyond logic.


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /