10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-27 06:43:48 +01:00
quantum_package/scripts/utility/decorator.py

18 lines
330 B
Python
Raw Normal View History

2015-06-04 17:37:43 +02:00
from functools import wraps
def cache(func):
"""
A decorator for lazy evaluation off true function
"""
saved = {}
@wraps(func)
def newfunc(*args):
if args in saved:
return saved[args]
result = func(*args)
saved[args] = result
return result
return newfunc