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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to