def save_pickle(obj, outfile, protocol=2):
    """Save the object as a pickle file

    Args:
        outfile (str): Filename
        protocol (int): Pickle protocol to use. Default is 2 to remain compatible with Python 2

    Returns:
        str: Path to pickle file

    """
    with open(outfile, 'wb') as f:
        pickle.dump(obj, f, protocol=protocol)

    return outfile
def save_pickle ( obj , outfile , protocol = 2 ) : with open ( outfile , 'wb' ) as f : pickle . dump ( obj , f , protocol = protocol ) return outfile
Save the object as a pickle file

    Args:
        outfile (str): Filename
        protocol (int): Pickle protocol to use. Default is 2 to remain compatible with Python 2

    Returns:
        str: Path to pickle file