summaryrefslogtreecommitdiff
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2018-12-26 10:46:03 -0800
committerGitHub <noreply@github.com>2018-12-26 10:46:03 -0800
commitba6ea52423d6b0d976c54b7effa218ce1fef1808 (patch)
tree63ff55181ca6dd88e74e292ec336b0ddd34bcaf5 /Lib/enum.py
parent34ae04f74dcf4ac97d07c3e82eaf8f619d80cedb (diff)
downloadcpython-git-revert-11318-fast-enum.tar.gz
Revert "Speed-up building enums by value, e.g. http.HTTPStatus(200) (#11318)"revert-11318-fast-enum
This reverts commit 34ae04f74dcf4ac97d07c3e82eaf8f619d80cedb.
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/enum.py b/Lib/enum.py
index f7452f0cc0..fec1aed9b2 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -563,10 +563,8 @@ class Enum(metaclass=EnumMeta):
# by-value search for a matching enum member
# see if it's in the reverse mapping (for hashable values)
try:
- return cls._value2member_map_[value]
- except KeyError:
- # Not found, no need to do long O(n) search
- pass
+ if value in cls._value2member_map_:
+ return cls._value2member_map_[value]
except TypeError:
# not there, now do long search -- O(n) behavior
for member in cls._member_map_.values():