def memoize_single_arg(f):
    """
    Decorator memoizing a single-argument function
    """
    memo = {}

    @wraps(f)
    def memoized_f(arg):
        try:
            return memo[arg]
        except KeyError:
            result = memo[arg] = f(arg)
            return result
    return memoized_f
Decorator memoizing a single-argument function