tries to load data, but computes it if it can't give a compute function

def tryload_cache_list_with_compute(use_cache, dpath, fname, cfgstr_list,
                                    compute_fn, *args):
    """
    tries to load data, but computes it if it can't give a compute function
    """
    # Load precomputed values
    if use_cache is False:
        data_list = [None] * len(cfgstr_list)
        ismiss_list = [True] * len(cfgstr_list)
        # Don't load or save, just compute
        data_list = compute_fn(ismiss_list, *args)
        return data_list
    else:
        data_list, ismiss_list = tryload_cache_list(dpath, fname, cfgstr_list,
                                                    verbose=False)
    num_total = len(cfgstr_list)
    if any(ismiss_list):
        # Compute missing values
        newdata_list = compute_fn(ismiss_list, *args)
        newcfgstr_list = util_list.compress(cfgstr_list, ismiss_list)
        index_list = util_list.list_where(ismiss_list)
        print('[cache] %d/%d cache hits for %s in %s' % (num_total -
                                                         len(index_list),
                                                         num_total, fname,
                                                         util_path.tail(dpath)))
        # Cache write
        for newcfgstr, newdata in zip(newcfgstr_list, newdata_list):
            save_cache(dpath, fname, newcfgstr, newdata, verbose=False)
        # Populate missing result
        for index, newdata in zip(index_list, newdata_list):
            data_list[index] = newdata
    else:
        print('[cache] %d/%d cache hits for %s in %s' % (num_total, num_total,
                                                         fname,
                                                         util_path.tail(dpath)))
    return data_list