Hi, I’d like to know what is the differences between the following ways of returning a generator
def genObj_0(self):
scene = bge.logic.getCurrentScene()
return (x for x in scene.objects)
def genObj_1(self):
scene = bge.logic.getCurrentScene()
yield [x for x in scene.objects]
def genObj_2(self):
scene = bge.logic.getCurrentScene()
yield from (x for x in scene.objects)
Do they work differently? I’m new to python and generator, the only thing I know is that it isn’t as memory intensive as list does when you iterate them for heavy operation
I think my main question is should I use function to return the generator?( If so then how do I do it correctly? )
Or should I just avoid function altogether? and use list comprehension?
objGen = (x for x in scene.objects)