class DecimalIndexing:

    def __init__(self, n):
        self.n = n

def __len__(self):
    return int(math.floor(math.log10(self.n) + 1))

def __getitem__(self, i):
    if isinstance(i, slice):
        return [self[x] for x in range(i.start, i.stop, i.step or 1)]
Find sequences of digits in long integers efficiently