'Get length of this integer set. In case the length is larger than
2**31 (including infinitely sized integer sets), it raises an
OverflowError. This is due to len() restricting the size to
0 <= len < 2**31.'

def __len__(self):

    if (not self._ranges):
        return 0
    if ((self._ranges[0][0] is _MININF) or (self._ranges[(-1)][1] is _MAXINF)):
        raise OverflowError('Infinitely    sized    integer    set.')
    rlen = 0
    for r in self._ranges:
        rlen += (r[1] - r[0])
    if (rlen >= (2 ** 31)):
        raise OverflowError('Integer    set    bigger    than    2**31.')
    return rlen
