import itertools


def safe_max(sequence, default=None):
    """
    Return the max value from sequence, if sequence is empty,
    return the default value.

    :param sequence: iterable sequence
    :param default: default value
    """
    i_seq = iter(sequence)
    try:
        value = next(i_seq)
    except StopIteration:
        return default

    return max(itertools.chain(sequence, [value]))