gh-109653: Improve enum import time by avoiding import of functools (GH-109789)

This commit is contained in:
Alex Waygood 2023-09-23 19:31:17 +01:00 committed by GitHub
parent e8be0c9c5a
commit 51863b7d6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View 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 @@ 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]

View file

@ -0,0 +1 @@
Reduce the import time of :mod:`enum` by over 50%. Patch by Alex Waygood.