Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a05d6c commit 0443953Copy full SHA for 0443953
1 file changed
Lib/enum.py
@@ -784,13 +784,8 @@ def __invert__(self):
784
785
786
def _high_bit(value):
787
- """return the highest bit set in value"""
788
- bit = 0
789
- while 'looking for the highest bit':
790
- limit = 2 ** bit
791
- if limit > value:
792
- return bit - 1
793
- 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
794
795
def unique(enumeration):
796
"""Class decorator for enumerations ensuring unique member values."""
0 commit comments