diff -r ebb23744a36c Lib/enum.py --- a/Lib/enum.py Wed Aug 31 23:00:32 2016 -0700 +++ b/Lib/enum.py Thu Sep 01 11:02:37 2016 +0200 @@ -785,12 +785,7 @@ class IntFlags(int, Flags): 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 + return value.bit_length() - 1 def unique(enumeration): """Class decorator for enumerations ensuring unique member values."""