def memodict(f):
    """ Memoization decorator for a function taking a single argument """
    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret 
    return memodict().__getitem__
 Memoization decorator for a function taking a single argument 
recipes/Python/578231_Probably_fastest_memoizatidecorator/recipe-578231.py