This may be a stupid question but I will ask it anyway. I have a generator object:
>>> def gen(): ... for i in range(10): ... yield i ..
__sizeof__ returns the memory size of an object in bytes, not the length of a generator, which is impossible to determine up front as generators can grow indefinitely.
__sizeof__