MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / get_spam

Function get_spam

src/8/creating_cached_instances/example1.py:11–17  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

9_spam_cache = weakref.WeakValueDictionary()
10
11def get_spam(name):
12 if name not in _spam_cache:
13 s = Spam(name)
14 _spam_cache[name] = s
15 else:
16 s = _spam_cache[name]
17 return s
18
19if __name__ == '__main__':
20 a = get_spam('foo')

Callers 1

example1.pyFile · 0.70

Calls 1

SpamClass · 0.70

Tested by

no test coverage detected