Advertisement
Guest User

Memoizing function skeleton

a guest
Apr 29th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement