import marshal
import types


def reconstruct_function(func_bytecode, func_defaults):
    """reconstruct function from bytecode.

    Args:
        func_bytecode (str) : the byte code of a function
        func_default  (dict): the default parameters of a function

    Returns: Function
    """
    func_code = marshal.loads(func_bytecode)
    return types.FunctionType(func_code, globals(), func_code.co_name,
                              func_defaults)