MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / KeyedRef

Class KeyedRef

tools/python-3.11.9-amd64/Lib/weakref.py:335–353  ·  view source on GitHub ↗

Specialized reference that includes a key corresponding to the value. This is used in the WeakValueDictionary to avoid having to create a function object for each key stored in the mapping. A shared callback object can use the 'key' attribute of a KeyedRef instead of getting a

Source from the content-addressed store, hash-verified

333
334
335class KeyedRef(ref):
336 """Specialized reference that includes a key corresponding to the value.
337
338 This is used in the WeakValueDictionary to avoid having to create
339 a function object for each key stored in the mapping. A shared
340 callback object can use the 'key' attribute of a KeyedRef instead
341 of getting a reference to the key from an enclosing scope.
342
343 """
344
345 __slots__ = "key",
346
347 def __new__(type, ob, callback, key):
348 self = ref.__new__(type, ob, callback)
349 self.key = key
350 return self
351
352 def __init__(self, ob, callback, key):
353 super().__init__(ob, callback)
354
355
356class WeakKeyDictionary(_collections_abc.MutableMapping):

Callers 3

__setitem__Method · 0.85
setdefaultMethod · 0.85
updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected