--- old/python/weakref.py +++ new/python/weakref.py @@ -206,7 +206,11 @@ if o is not None: L.append(o) return L - + + def clear(self): + L = self.data.keys(); + self.data.clear(); + del L class KeyedRef(ref): """Specialized reference that includes a key corresponding to the value. @@ -377,3 +381,8 @@ d[ref(key, self._remove)] = value if len(kwargs): self.update(kwargs) + + def clear(self): + L = self.data.values(); + self.data.clear(); + del L