Skip to content

Commit 59e9e8a

Browse files
ukleinekstephenfin
authored andcommitted
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 91a68dc commit 59e9e8a

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
@@ -678,7 +678,7 @@ def project_list(self, search_str=None, max_count=0):
678678
)
679679

680680
projects = self._list('projects')
681-
return [self._project_to_dict(project) for project in projects]
681+
return (self._project_to_dict(project) for project in projects)
682682

683683
def project_get(self, project_id):
684684
project = self._detail('projects', project_id)
@@ -713,7 +713,7 @@ def person_list(self, search_str=None, max_count=0):
713713
)
714714

715715
people = self._list('people')
716-
return [self._person_to_dict(person) for person in people]
716+
return (self._person_to_dict(person) for person in people)
717717

718718
def person_get(self, person_id):
719719
person = self._detail('people', person_id)
@@ -805,7 +805,7 @@ def patch_list(
805805
filters['delegate'] = delegate
806806

807807
patches = self._list('patches', params=filters)
808-
return [self._patch_to_dict(patch) for patch in patches]
808+
return (self._patch_to_dict(patch) for patch in patches)
809809

810810
def patch_get(self, patch_id):
811811
patch = self._detail('patches', patch_id)

0 commit comments

Comments
 (0)