Why does list iterator generate a Sequence instead of flat ObjectMeta's?
#661
|
When I call for seq in store.list('prefix'): # Only does 1 iteration
for obj in seq:
obj["path"]instead of for obj in store.list('prefix'):
obj["path"]Meanwhile |
Replies: 1 comment
|
It's like this to express chunking and give insight into the batching and network requests that are happening under the hood. When you have an AsyncGenerator that yields bare Conversely, Does this help? |
It's like this to express chunking and give insight into the batching and network requests that are happening under the hood.
When you have an AsyncGenerator that yields bare
ObjectMeta, you never know when the nextasync foriteration will be already buffered or cause another network request. But when the AsyncGenerator yieldsSequence[ObjectMeta], you are able to inspect the full buffering yourself. If you need more items than exist in the current sequence, then you can callanext(), but you know you're incurring a network request there.Conversely,
collectsays "I want to materialize the entire list of results". So at that point you don't care how many requests it took to create itDoe…