Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@keygen('x',2,tol=2)
def add(w,x,y,z):
return x+y+z+w
@keygen('self')
def bar(self, x,y):
return x+y
@keygen('x','**')
def foo(x,y,z=2):
return x+y+z
_add(4,debug=True)
_add(2,0,3)
_add(2,0,4)
_cache = _add.__cache__()
_func = _add.__wrapped__
# do a lookup
assert _add.lookup(2,0) == _func(2,0)
# generate the key, and do a look-up
key = _add.key(2,0)
assert _cache[key] == _func(2,0)
# look-up the key again, doing a little more work...
lookup = keygen('self','**')(_func)
lookup.register(hasher)
key = lookup(2,0)
assert _cache[key] == _func(2,0)
# since we have the 'key lookup', let's play with lookup a bit
assert lookup.valid()
assert lookup.call() == _func(2,0)