Skip to content

Instantly share code, notes, and snippets.

@JamesTheAwesomeDude
Last active March 24, 2023 14:39
Show Gist options
  • Save JamesTheAwesomeDude/89a79b35eb2e295bb62cca4e15d6a9be to your computer and use it in GitHub Desktop.
Save JamesTheAwesomeDude/89a79b35eb2e295bb62cca4e15d6a9be to your computer and use it in GitHub Desktop.
Normalize function inputs before LRU cache
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