pickle and compress an object

def pickle_compress(obj, print_compression_info=False):
    """pickle and compress an object"""
    p = pickle.dumps(obj)
    c = zlib.compress(p)
    if print_compression_info:
        print ("len = {:,d} compr={:,d} ratio:{:.6f}".format(len(p), len(c), float(len(c))/len(p)))
    return c