def memoize(call):
    """Automatically memoize a callable."""

    results = {}

    def wrapper(*args, **kwargs):
        key = (tuple(args), tuple(sorted(kwargs.iteritems())))

        try:
            return results[key]
        except __HOLE__:
            results[key] = result = call(*args, **kwargs)

            return result

    return wrapper
dataset/ETHPy150Open borg-project/borg/borg/util.py/memoize