aboutsummaryrefslogtreecommitdiff
blob: 93502c5d200445be0ded7d6dc56961b230f5b12b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
"""
Caches the return value of a function -> Result, regardless of input params
"""
class cached():
    """
    A decorator to make the function cache its return value, regardless of input
    """
    def __init__(self, fun):
        self.fun = fun
    def __call__(self, *args):
        if not hasattr(self, 'retval'):
            self.retval = self.fun(*args).unwrap()
        return self.retval