issue23591: optimize _high_bit()
This commit is contained in:
parent
1a05d6c04d
commit
0443953067
|
@ -784,13 +784,8 @@ class IntFlag(int, Flag):
|
||||||
|
|
||||||
|
|
||||||
def _high_bit(value):
|
def _high_bit(value):
|
||||||
"""return the highest bit set in value"""
|
"""returns index of highest bit, or -1 if value is zero or negative"""
|
||||||
bit = 0
|
return value.bit_length() - 1 if value > 0 else -1
|
||||||
while 'looking for the highest bit':
|
|
||||||
limit = 2 ** bit
|
|
||||||
if limit > value:
|
|
||||||
return bit - 1
|
|
||||||
bit += 1
|
|
||||||
|
|
||||||
def unique(enumeration):
|
def unique(enumeration):
|
||||||
"""Class decorator for enumerations ensuring unique member values."""
|
"""Class decorator for enumerations ensuring unique member values."""
|
||||||
|
|
Loading…
Reference in New Issue