The WeakKeyDictionary and WeakValueDictionary don't provide any API to get just the weakrefs out, instead of the usual mapping API. This can be desirable when you want to get a list of everything without creating new references to the underlying objects at that moment. This patch adds methods to make the references themselves accessible using the API, avoiding requiring client code to have to depend on the implementation. The WeakKeyDictionary gains the .iterkeyrefs() and .keyrefs() methods, and the WeakValueDictionary gains the .itervaluerefs() and .valuerefs() methods. The patch includes tests and docs.
Logged In: YES user_id=3066 Tim noted in email: http://mail.python.org/pipermail/python-dev/2006-May/064751.html that the implementation could and probably should be simplified. This second version of the patch does that, and updates the documentation to note the liveness issues of the references, as well as avoid repetition.