From 972d93a95ec8b37fab84400417070b7439414967 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Mon, 16 Dec 2019 12:22:45 +0200 Subject: [PATCH] Optimized containment check in ChoicesMeta. --- django/db/models/enums.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/db/models/enums.py b/django/db/models/enums.py index ae20ef6d93..f48143ddaf 100644 --- a/django/db/models/enums.py +++ b/django/db/models/enums.py @@ -36,7 +36,7 @@ class ChoicesMeta(enum.EnumMeta): def __contains__(cls, member): if not isinstance(member, enum.Enum): # Allow non-enums to match against member values. - return member in {x.value for x in cls} + return any(x.value == member for x in cls) return super().__contains__(member) @property