Skip to content

Commit

Permalink
Update for loop to use walrus operator (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
brainix committed Oct 8, 2023
1 parent 155fe24 commit 3cccf81
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions pottery/bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,7 @@ def contains_many(self, *values: JSONTypes) -> Generator[bool, None, None]:

# I stole this recipe from here:
# https://stackoverflow.com/a/61435714
#
# TODO: When we drop support for Python 3.7, rewrite the following loop
# using the walrus operator, like in the Stack Overflow answer linked
# above.
bits_per_chunk = self.num_hashes()
while True:
bits_in_chunk = tuple(itertools.islice(bits, bits_per_chunk))
while bits_in_chunk := tuple(itertools.islice(bits, self.num_hashes())):
if not bits_in_chunk:
break
yield all(bits_in_chunk)
Expand Down

0 comments on commit 3cccf81

Please sign in to comment.