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:

  1. 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.
  2. enumerate starts @ index 0, construct return 1 less actual length of iterator.

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -