def median(iterable):
    """
    Compute the median value in the given iterable - which must be finite and non-empty.
    """
    values = sorted(iterable)
    le = len(values)
    assert le
    if le % 2 == 1:
        return values[le // 2]
    else:
        return (values[le // 2 - 1] + values[le // 2]) / 2