def from_changes(cls, startval, changes):
        """Alternative constructor from an start value and iterable of changes.

        x = cls.from_changes(startval, changes)
        is equivalent (albeit more efficient) to
        x = cls()
        x[:] = startval
        for bound, val in changes:
            x[bound:] = val
        """
        
        res = cls()
        bounds, values = res._bounds, res._values
        res._values[0] = startval
        last_v = object() # compares different from anything
        for b, v in changes:
            if v == last_v:
                continue
            bounds.append(b)
            values.append(v)
            last_v = v
        return res
Alternative constructor from an start value and iterable of changes.

        x = cls.from_changes(startval, changes)
        is equivalent (albeit more efficient) to
        x = cls()
        x[:] = startval
        for bound, val in changes:
            x[bound:] = val
        
recipes/Python/577515_interval_mapping/recipe-577515.py