@extensionmethod(Observable)
def distinct_until_changed(self, key_selector=None, comparer=None):

    source = self
    key_selector = key_selector or identity
    comparer = comparer or default_comparer

    def subscribe(observer):
        has_current_key = [False]
        current_key = [None]

        def on_next(value):
            comparer_equals = False
            try:
                key = key_selector(value)
            except Exception as exception:
                observer.on_error(exception)
                return

            if has_current_key[0]:
                try:
                    comparer_equals = comparer(current_key[0], key)
                except Exception as exception:
                    observer.on_error(exception)
                    return

            if not has_current_key[0] or not comparer_equals:
                has_current_key[0] = True
                current_key[0] = key
                observer.on_next(value)

        return source.subscribe(on_next, observer.on_error, observer.on_completed)
    return AnonymousObservable(subscribe)
get the slice.
dataset/ETHPy150Open ReactiveX/RxPY/rx/linq/observable/distinctuntilchanged.py/distinct_until_changed--crossover with--dataset/ETHPy150Open mne-tools/mne-python/mne/cov.py/_get_tslice