Add memoization in basic_modif.py

This commit is contained in:
Clément Barthélemy 2024-02-24 03:57:37 +01:00
parent 948e4da10c
commit c54793c406
3 changed files with 26 additions and 9 deletions

View file

@ -0,0 +1,8 @@
def memoize(f):
cache = {}
def memoized_function(*args):
if args not in cache:
cache[args] = f(*args)
return cache[args]
return memoized_function