pr3-python-sose2026/assignments/gehalt.py

24 lines
462 B
Python

import time
def cache(func):
cache_dict = {}
def wrapper(*args):
if args[0] in cache_dict:
print("Gehalt vom Cache gehlot")
return cache_dict[args[0]]
else:
print("Gehalt wird gerechnet...")
result = func(args[0])
cache_dict[args[0]] = result
return result
return wrapper
@cache
def gehalt(name):
# Komplexe Berechnung
time.sleep(3)
return 3000