MCPcopy Create free account
hub / github.com/ActiveState/code / set

Method set

recipes/Python/577580_weak_reference_map/recipe-577580.py:34–41  ·  view source on GitHub ↗
(self, key, value)

Source from the content-addressed store, hash-verified

32 self.__backref = {}
33
34 def set(self, key, value):
35 ikey, ival = id(key), id(value)
36 self.__map[ikey] = (ival,
37 _ref(key, partial(self.forget_key, ikey))
38 )
39 if ival not in self.__valmemo:
40 self.__valmemo[ival] = _ref(value, partial(self.forget_value, ival))
41 self.__backref.setdefault(ival, set()).add(ikey)
42
43 def get(self, key, **kwargs):
44 ikey = id(key)

Callers 4

_write_Method · 0.45
updateMethod · 0.45
_write_Method · 0.45
build_treeMethod · 0.45

Calls 5

_refFunction · 0.85
partialFunction · 0.85
setFunction · 0.50
addMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected