Created
October 19, 2015 23:10
-
-
Save jimmybot/3400668da8c847cc2e9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def logger(fn): | |
start = time() | |
fn() | |
end = time() | |
print("time taken was: ", end - start) | |
return inner | |
def memoize(fn): | |
memory = {} | |
def fn2(*args): | |
if args in memory: | |
return memory[args] | |
else: | |
ret = fn(*args) | |
memory[ret] | |
return ret | |
return fn2 | |
newfn = memoize(calculationthattakesalongtimefactorial) | |
newfn(99) | |
newfn(99) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment