Skip to content

Instantly share code, notes, and snippets.

@haleyrc
Created December 3, 2012 22:20
Show Gist options
  • Select an option

  • Save haleyrc/4198663 to your computer and use it in GitHub Desktop.

Select an option

Save haleyrc/4198663 to your computer and use it in GitHub Desktop.
Basic Memoization Class
class Memoize:
def __init__(self, func):
self.prevs = {}
self.func = func
def __call__(self, *args):
if not args in self.prevs:
self.prevs[args] = self.func(*args)
return self.prevs[args]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment