Last active
March 24, 2023 14:39
-
-
Save JamesTheAwesomeDude/89a79b35eb2e295bb62cca4e15d6a9be to your computer and use it in GitHub Desktop.
Normalize function inputs before LRU cache
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
import functools | |
from .. import NORMALIZE_FUNC, EXPENSIVE_API_CALL | |
@(lambda t: lambda f: functools.wraps(f)(lambda x: f(t(x))))(NORMALIZE_FUNC) | |
@functools.lru_cache | |
def f(x): | |
return EXPENSIVE_API_CALL(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment