def iteratorCreationTiming():
    def getIterable(x):
        print("Getting iterable", x)
        return Iterable(x)

    class Iterable:
        def __init__(self, x):
            self.x = x
            self.values = list(range(x))
            self.count = 0

        def __iter__(self):
            print("Giving iterator now", self.x)

            return self

        def __next__(self):
            print("Next of", self.x, "is", self.count)

            if len(self.values) > self.count:
                self.count += 1

                return self.values[ self.count - 1 ]
            else:
                print("Raising StopIteration for", self.x)

                raise StopIteration

        # Python2/3 compatibility.
        next = __next__

        def __del__(self):
            print("Deleting", self.x)


    gen = ( (y,z) for y in getIterable(3) for z in getIterable(2) )

    print("Using generator", gen)
    next(gen)
    res = tuple(gen)
    print(res)

    print('*' * 20)

    try:
        next(gen)
    except __HOLE__:
        print("Usage past end gave StopIteration exception as expected.")

        try:
            print("Generator state then is", inspect.getgeneratorstate(gen))  # @UndefinedVariable
        except AttributeError:
            pass

        print("Its frame is now", gen.gi_frame)

    print("Early aborting generator:")

    gen2 = ( (y,z) for y in getIterable(3) for z in getIterable(2) )
    del gen2
dataset/ETHPy150Open kayhayen/Nuitka/tests/basics/GeneratorExpressions.py/iteratorCreationTiming