SHARE
TWEET

Memoizing function skeleton

a guest Apr 29th, 2013 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stash = {}
  2. def f(a, b, c):
  3.     if (a, b, c) in stash:
  4.         return stash[a, b, c]
  5.     else:
  6.         # long expensive computation
  7.         stash[a, b, c] = result
  8.         return result
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top