30 Jun
2013
30 Jun
'13
10:08 p.m.
Ron Adam wrote:
It's the same as in-lineing the generator parts into the iterator that is driving it.
We don't need to do that because we already have an optimised version of that. It just needs to catch the StopIteration to be the same.
I think that it's not uncommon for people to think this is how list comps work. And I think it is surprising for them that the StopIteration isn't caught.
I tend to feel that the fact that raising StopIteration in a generator has the same effect as returning from the generator is a quirk of the implementation that shouldn't be relied on. I'm not sure we should be giving it official status by going out of our way to make listcomps behave the same. -- Greg