Commit 04439530 authored by Ethan Furman's avatar Ethan Furman

issue23591: optimize _high_bit()

parent 1a05d6c0
......@@ -784,13 +784,8 @@ class IntFlag(int, Flag):
def _high_bit(value):
"""return the highest bit set in value"""
bit = 0
while 'looking for the highest bit':
limit = 2 ** bit
if limit > value:
return bit - 1
bit += 1
"""returns index of highest bit, or -1 if value is zero or negative"""
return value.bit_length() - 1 if value > 0 else -1
def unique(enumeration):
"""Class decorator for enumerations ensuring unique member values."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment