My current approach is:
rowiter = atable.where(condition)
rowiter_length = max([i for i, row in enumerate(rowiter)])
Is there a way to get the length of rowiter without looping through the entire iterator?
My current approach is:
rowiter = atable.where(condition)
rowiter_length = max([i for i, row in enumerate(rowiter)])
Is there a way to get the length of rowiter without looping through the entire iterator?
Not sure if there's a more efficient way, but you should really just be using len(rowiter)
instead of that list comp, for two reasons:
__len__
special method, so you'll get the speedup if it's available.enumerate
starts at index 0, so your construct will return 1 less than the actual length of the iterator.