Skip to content

Commit 7cb9da6

Browse files
committed
api/rest: Let p{roject,eople,atches}_list return a generator
This has the advantage that with pagination the first entries are already provided before later entries are queried from the server. Also if the generator isn't walked through completely, only the needed queries are actually executed. All callers of these functions can cope with the returned object being a generator now instead of a list as they just iterate once over it.
1 parent dc8c6ba commit 7cb9da6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pwclient/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def project_list(self, search_str=None, max_count=0):
644644
)
645645

646646
projects = self._list('projects')
647-
return [self._project_to_dict(project) for project in projects]
647+
return (self._project_to_dict(project) for project in projects)
648648

649649
def project_get(self, project_id):
650650
project = self._detail('projects', project_id)
@@ -679,7 +679,7 @@ def person_list(self, search_str=None, max_count=0):
679679
)
680680

681681
people = self._list('people')
682-
return [self._person_to_dict(person) for person in people]
682+
return (self._person_to_dict(person) for person in people)
683683

684684
def person_get(self, person_id):
685685
person = self._detail('people', person_id)
@@ -771,7 +771,7 @@ def patch_list(
771771
filters['delegate'] = delegate
772772

773773
patches = self._list('patches', params=filters)
774-
return [self._patch_to_dict(patch) for patch in patches]
774+
return (self._patch_to_dict(patch) for patch in patches)
775775

776776
def patch_get(self, patch_id):
777777
patch = self._detail('patches', patch_id)

0 commit comments

Comments
 (0)