def memoize_simplifier()

in access/simplifiers.py [0:0]


def memoize_simplifier(simplifier):
    memo = {}

    @wraps(simplifier)
    def wrapped(complex_filepath, pred_filepath):
        complex_filehash = hashfile(complex_filepath, hexdigest=True)
        previous_pred_filepath = memo.get(complex_filehash)
        if previous_pred_filepath is not None and Path(previous_pred_filepath).exists():
            assert count_lines(complex_filepath) == count_lines(previous_pred_filepath)
            # Reuse previous prediction
            shutil.copyfile(previous_pred_filepath, pred_filepath)
        else:
            simplifier(complex_filepath, pred_filepath)
        # Save prediction
        memo[complex_filehash] = pred_filepath

    return wrapped