diff --git a/interp/baker/__init__.py b/interp/baker/__init__.py index c87b027..e2bb5e9 100644 --- a/interp/baker/__init__.py +++ b/interp/baker/__init__.py @@ -204,6 +204,16 @@ def _samples_ur(items, k, offset = 0): selections = [[items[i]]*count for i,count in enumerate(sample)] yield tuple([x + offset for sel in selections for x in sel]) +def memoize(f): + cache = {} + def memf(*x, **kargs): + if x not in cache: + print >>sys.stderr, x, kargs + cache[x] = f(*x, **kargs) + return cache[x] + return memf + +@memoize def pattern(power, phicount, offset = 0): log.debug("(power = %s, phicount = %s)" % (power, phicount)) r = []