import bz2
import pickle


def zdumps(obj):
    """
    dumps pickleable object into bz2 compressed string

    :param obj: The object/function to store.
    :type obj: object or function

    :returns: An bz2-compressed pickle of the given object.
    """
    return bz2.compress(pickle.dumps(obj, pickle.HIGHEST_PROTOCOL), 9)
    # return pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)