Last active
January 25, 2019 15:55
-
-
Save deque-blog/af6d3e3a5fe48f86a33e176264cf0116 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@functools.lru_cache(maxsize=2) | |
def long_computation(arg): | |
print("Long computation", arg) | |
return ... | |
for arg in [1,2,3] * 2: | |
long_computation(arg) | |
# Will print (only cache misses!) | |
"Long computation 1" | |
"Long computation 2" | |
"Long computation 3" | |
"Long computation 1" | |
"Long computation 2" | |
"Long computation 3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment