]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109653: Improve `enum` import time by avoiding import of `functools` (GH-109789)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Sat, 23 Sep 2023 18:31:17 +0000 (19:31 +0100)
committerGitHub <noreply@github.com>
Sat, 23 Sep 2023 18:31:17 +0000 (11:31 -0700)
Lib/enum.py
Misc/NEWS.d/next/Library/2023-09-23-12-47-45.gh-issue-109653.9wZBfs.rst [new file with mode: 0644]

index 994a7b9c73f9a71ce5c9d5aeac01e93db7a8429f..f5448a1788e4d2b7163f5a1786fba60d0db3ec7c 100644 (file)
@@ -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 @@ class verify:
                     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 (file)
index 0000000..1d0f0e4
--- /dev/null
@@ -0,0 +1 @@
+Reduce the import time of :mod:`enum` by over 50%. Patch by Alex Waygood.