Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
04439530
Commit
04439530
authored
Sep 02, 2016
by
Ethan Furman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue23591: optimize _high_bit()
parent
1a05d6c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
7 deletions
+2
-7
Lib/enum.py
Lib/enum.py
+2
-7
No files found.
Lib/enum.py
View file @
04439530
...
...
@@ -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."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment