python - What is the best way to get the number of elements in a PyTables row iterator? -
my current approach is:
rowiter = atable.where(condition) rowiter_length = max([i i, row in enumerate(rowiter)])
is there way length of rowiter without looping through entire iterator?
not sure if there's more efficient way, should using len(rowiter)
instead of list comp, 2 reasons:
- if iterator object have more efficient way of calculating length, it'll have made accessible via
__len__
special method, you'll speedup if it's available. enumerate
starts @ index 0, construct return 1 less actual length of iterator.
Comments
Post a Comment