@extensionmethod(Observable, name="slice")
def slice_(self, start=None, stop=None, step=1):

    source = self

    if start is not None:
        if start < 0:
            source = source.take_last(abs(start))
        else:
            source = source.skip(start)

    if stop is not None:
        if stop > 0:
            start = start or 0
            source = source.take(stop - start)
        else:
            source = source.skip_last(abs(stop))

    if step is not None:
        if step > 1:
            source = source.filter(lambda x, i: i % step == 0)
        elif step < 0:
            # Reversing events is not supported
            raise TypeError("Negative step not supported.")

    return source
Patches P.eval with the orm_eval version for debugging and validation.
dataset/ETHPy150Open ReactiveX/RxPY/rx/linq/observable/slice.py/slice_--crossover with--dataset/ETHPy150Open django-predicate/django-predicate/predicate/debug.py/patch_with_orm_eval