Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit e1d4075

Browse files
committed
slimming iterator
1 parent 1cb8abf commit e1d4075

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cloudant/result.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""
1616
API module for interacting with result collections.
1717
"""
18+
from collections import deque
1819
from functools import partial
1920
from ._2to3 import STRTYPE
2021
from .error import ResultException
@@ -378,12 +379,12 @@ def _iterator(self, response):
378379
'''
379380

380381
while True:
381-
result = self._parse_data(response)
382+
result = deque(self._parse_data(response))
382383
if result:
383384
doc_count = len(result)
384385
last = result.pop()
385-
for row in result:
386-
yield row
386+
while result:
387+
yield result.popleft()
387388

388389
# We expect doc_count = self._page_size + 1 results, if
389390
# we have self._page_size or less it means we are on the

0 commit comments

Comments
 (0)