1 # This Python file uses the following encoding: utf-8
3 Created on May 12, 2011
10 class Memoized(object):
11 def __init__(self
, f
):
15 def __call__(self
, *args
):
17 if key
in self
.__cache
:
18 return self
.__cache
[key
]
20 result
= self
.__f
(*args
)
21 self
.__cache
[key
] = result
25 """Return the function's docstring."""
26 return self
.func
.__doc
__
28 def __get__(self
, obj
, objtype
):
29 """Support instance methods."""
30 return functools
.partial(self
.__call
__, obj
)