import zlib
import pickle


def blobdumps(py_obj, cPickle_protocol=2, compression_level=7):
    """
    Pickle any Python object, and compress the pickled object.

    Returns a binary string.

    `compression_level`: Between 1 and 9
        The higher the level is, the more compressed the object will be.
    """

    return zlib.compress(pickle.dumps(py_obj, cPickle_protocol),
                         compression_level).decode('latin1')