def __setitem__(self, p: Union[(int, slice)], v: T) -> None:
    if hasattr(v, 'set_parent'):
        v.set_parent(self)
    if (type(p) is int):
        self._setitem_single(p, v)
        self._merge_redundant()
        self._needs_update()
        return
    if (type(p) is not slice):
        raise TypeError('Excepted int or slice!')
    start = (p.start or 0)
    stop = (p.stop or INFINITY)
    orig_value = self[stop]
    (start_idx, _) = self._setitem_single(start, v)
    (end_idx, hit_end) = self._find_index(stop)
    if ((not hit_end) and (stop < INFINITY)):
        (end_idx, _) = self._setitem_single(stop, orig_value)
    if (stop == INFINITY):
        end_idx += 1
    del self._values[(start_idx + 1):end_idx]
    self._merge_redundant()
    self._needs_update()
def __setitem__(self, p: Union[(int, slice)], v: T) -> None:
    if hasattr(v, 'set_parent'):
        v.set_parent(self)
    if (type(p) is int):
        self._setitem_single(p, v)
        self._merge_redundant()
        self._needs_update()
        return
    if (type(p) is not slice):
        raise TypeError('Excepted int or slice!')
    start = (p.start or 0)
    stop = (p.stop or INFINITY)
    orig_value = self[stop]
    (start_idx, _) = self._setitem_single(start, v)
    (end_idx, hit_end) = self._find_index(stop)
    if ((not hit_end) and (stop < INFINITY)):
        (end_idx, _) = self._setitem_single(stop, orig_value)
    if (stop == INFINITY):
        end_idx += 1
    del self._values[(start_idx + 1):end_idx]
    self._merge_redundant()
    self._needs_update()