Skip to content

Commit

Permalink
speed up bit iterator calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBin committed Oct 13, 2021
1 parent 41efb50 commit 99f78d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions owlapy/util.py
Expand Up @@ -422,9 +422,9 @@ def iter_bits(v: int) -> Iterable[int]:
numbers with only one bit set
"""
while v:
b = v & (~v + 1)
b = 1 << v.bit_length() - 1
yield b
v ^= b
v -= b


def iter_count(i: Iterable) -> int:
Expand Down

0 comments on commit 99f78d2

Please sign in to comment.