import pickle

def read_pickle(path):
    with open(path, "rb") as f:
        x = pickle.load(f)
    return x

def write_pickle(x, path):
    with open(path, 'wb') as handle:
        pickle.dump(x, handle, protocol=pickle.HIGHEST_PROTOCOL)