'Retrieves an item or slice from the set of results.'

def __getitem__(self, k):

    if (not isinstance(k, (slice, six.integer_types))):
        raise TypeError
    assert (((not isinstance(k, slice)) and (k >= 0)) or (isinstance(k, slice) and ((k.start is None) or (k.start >= 0)) and ((k.stop is None) or (k.stop >= 0)))), u'Negative    indexing    is    not    supported.'
    if isinstance(k, slice):
        is_slice = True
        start = k.start
        if (k.stop is not None):
            bound = int(k.stop)
        else:
            bound = None
    else:
        is_slice = False
        start = k
        bound = (k + 1)
    if ((len(self._result_cache) <= 0) or ((None in self._result_cache[start:bound]) and (not self._cache_is_full()))):
        try:
            self._fill_cache(start, bound)
        except StopIteration:
            pass
    if is_slice:
        return self._result_cache[start:bound]
    else:
        return self._result_cache[start]
