memoized the pattern function
This commit is contained in:
parent
e65f67893d
commit
a732d82a98
@ -204,6 +204,16 @@ def _samples_ur(items, k, offset = 0):
|
|||||||
selections = [[items[i]]*count for i,count in enumerate(sample)]
|
selections = [[items[i]]*count for i,count in enumerate(sample)]
|
||||||
yield tuple([x + offset for sel in selections for x in sel])
|
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):
|
def pattern(power, phicount, offset = 0):
|
||||||
log.debug("(power = %s, phicount = %s)" % (power, phicount))
|
log.debug("(power = %s, phicount = %s)" % (power, phicount))
|
||||||
r = []
|
r = []
|
||||||
|
Loading…
Reference in New Issue
Block a user