Skip to content

Commit 8f2ba1b

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 02aac3d commit 8f2ba1b

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
@@ -640,7 +640,7 @@ def project_list(self, search_str=None, max_count=0):
640640
)
641641

642642
projects = self._list('projects')
643-
return [self._project_to_dict(project) for project in projects]
643+
return (self._project_to_dict(project) for project in projects)
644644

645645
def project_get(self, project_id):
646646
project = self._detail('projects', project_id)
@@ -675,7 +675,7 @@ def person_list(self, search_str=None, max_count=0):
675675
)
676676

677677
people = self._list('people')
678-
return [self._person_to_dict(person) for person in people]
678+
return (self._person_to_dict(person) for person in people)
679679

680680
def person_get(self, person_id):
681681
person = self._detail('people', person_id)
@@ -767,7 +767,7 @@ def patch_list(
767767
filters['delegate'] = delegate
768768

769769
patches = self._list('patches', params=filters)
770-
return [self._patch_to_dict(patch) for patch in patches]
770+
return (self._patch_to_dict(patch) for patch in patches)
771771

772772
def patch_get(self, patch_id):
773773
patch = self._detail('patches', patch_id)

0 commit comments

Comments
 (0)