diff --git a/Lib/enum.py b/Lib/enum.py index 994a7b9c73f9a7..f5448a1788e4d2 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1,8 +1,6 @@ import sys import builtins as bltns from types import MappingProxyType, DynamicClassAttribute -from operator import or_ as _or_ -from functools import reduce __all__ = [ @@ -1884,7 +1882,8 @@ def __call__(self, enumeration): missed = [v for v in values if v not in member_values] if missed: missing_names.append(name) - missing_value |= reduce(_or_, missed) + for val in missed: + missing_value |= val if missing_names: if len(missing_names) == 1: alias = 'alias %s is missing' % missing_names[0] diff --git a/Misc/NEWS.d/next/Library/2023-09-23-12-47-45.gh-issue-109653.9wZBfs.rst b/Misc/NEWS.d/next/Library/2023-09-23-12-47-45.gh-issue-109653.9wZBfs.rst new file mode 100644 index 00000000000000..1d0f0e4f83b5e1 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-09-23-12-47-45.gh-issue-109653.9wZBfs.rst @@ -0,0 +1 @@ +Reduce the import time of :mod:`enum` by over 50%. Patch by Alex Waygood.