Skip to content

Commit 51863b7

Browse files
authored
gh-109653: Improve enum import time by avoiding import of functools (GH-109789)
1 parent e8be0c9 commit 51863b7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/enum.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import sys
22
import builtins as bltns
33
from types import MappingProxyType, DynamicClassAttribute
4-
from operator import or_ as _or_
5-
from functools import reduce
64

75

86
__all__ = [
@@ -1884,7 +1882,8 @@ def __call__(self, enumeration):
18841882
missed = [v for v in values if v not in member_values]
18851883
if missed:
18861884
missing_names.append(name)
1887-
missing_value |= reduce(_or_, missed)
1885+
for val in missed:
1886+
missing_value |= val
18881887
if missing_names:
18891888
if len(missing_names) == 1:
18901889
alias = 'alias %s is missing' % missing_names[0]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reduce the import time of :mod:`enum` by over 50%. Patch by Alex Waygood.

0 commit comments

Comments
 (0)