Skip to content

Commit fd8b9a9

Browse files
[Feature] Compare future results based on id (#1013)
* [Feature] Compare future results based on id * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 49fca86 commit fd8b9a9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/executorlib/standalone/batched.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def batched_futures(lst: list[Future], skip_lst: list[list], n: int) -> list[lis
1515
Returns:
1616
list: results of the batched futures
1717
"""
18-
skipped_elements_lst = [item for items in skip_lst for item in items]
18+
skipped_ids = {id(item) for items in skip_lst for item in items}
1919

2020
done_lst = []
21-
n_expected = min(n, len(lst) - len(skipped_elements_lst))
21+
n_expected = min(n, len(lst) - len(skipped_ids))
2222
for v in lst:
23-
if v.done() and v.result() not in skipped_elements_lst:
23+
if v.done() and id(v.result()) not in skipped_ids:
2424
done_lst.append(v.result())
25-
if len(done_lst) == n_expected:
26-
return done_lst
25+
if len(done_lst) == n_expected:
26+
return done_lst
2727
return []

0 commit comments

Comments
 (0)