Memoized lazy evaluation. The function is only evaluated once, every subsequent access will return the same value.
| 37 | |
| 38 | |
| 39 | class mlazy(lazy): |
| 40 | """Memoized lazy evaluation. |
| 41 | |
| 42 | The function is only evaluated once, every subsequent access |
| 43 | will return the same value. |
| 44 | """ |
| 45 | |
| 46 | #: Set to :const:`True` after the object has been evaluated. |
| 47 | evaluated = False |
| 48 | _value = None |
| 49 | |
| 50 | def evaluate(self): |
| 51 | if not self.evaluated: |
| 52 | self._value = super().evaluate() |
| 53 | self.evaluated = True |
| 54 | return self._value |
| 55 | |
| 56 | |
| 57 | def noop(*args, **kwargs): |
no outgoing calls