MCPcopy Create free account
hub / github.com/numpy/numpy / _memoize

Function _memoize

numpy/f2py/tests/util.py:76–93  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

74
75
76def _memoize(func):
77 memo = {}
78
79 def wrapper(*a, **kw):
80 key = repr((a, kw))
81 if key not in memo:
82 try:
83 memo[key] = func(*a, **kw)
84 except Exception as e:
85 memo[key] = e
86 raise
87 ret = memo[key]
88 if isinstance(ret, Exception):
89 raise ret
90 return ret
91
92 wrapper.__name__ = func.__name__
93 return wrapper
94
95
96#

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected