def _padded(region, pad):
    """
    >>> _padded([1, 1, 4, 4], [0, 1, 2 ,3])
    (1, 0, 6, 7)
    >>> _padded([1, 1, 4, 4], 2)
    (-1, -1, 6, 6)
    """
    if not pad:
        return region
    if isinstance(pad, (int, float)):
        pad = pad, pad, pad, pad
    return region[0] - pad[0], region[1] - pad[1], region[2] + pad[2], region[3
        ] + pad[3]
