[Python-Dev] weakref enhancements
tomer filiba
tomerfiliba at gmail.com
Thu Sep 28 20:40:34 CEST 2006
i'd like to suggest adding weak attributes and weak methods to the std
weakref
module.
weakattrs are weakly-referenced attributes. when the value they reference is
no
longer strongly-referenced by something else, the weakattrs "nullify"
themselves.
weakmethod is a method decorator, like classmethod et al, that returns
"weakly
bound" methods. weakmethod's im_self is a weakref.proxy to `self`, which
means
the mere method will not keep the entire instance alive. instead, you'll get
a
ReferenceError.
i think these two features are quite useful, and being part of the stdlib,
would
provide programmers with easy-to-use solutions to object-aliveness issues.
more info, examples, and suggested implementation:
* http://sebulba.wikispaces.com/recipe+weakattr
* http://sebulba.wikispaces.com/recipe+weakmethod
-tomer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060928/7c3f1fc2/attachment.html
More information about the Python-Dev
mailing list