mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-30152: Reduce the number of imports for argparse. (#1269)
This commit is contained in:
parent
f1502d097c
commit
81108375d9
8 changed files with 59 additions and 49 deletions
11
Lib/enum.py
11
Lib/enum.py
|
@ -1,7 +1,5 @@
|
|||
import sys
|
||||
from types import MappingProxyType, DynamicClassAttribute
|
||||
from functools import reduce
|
||||
from operator import or_ as _or_
|
||||
|
||||
# try _collections first to reduce startup cost
|
||||
try:
|
||||
|
@ -744,11 +742,10 @@ class Flag(Enum):
|
|||
|
||||
def __invert__(self):
|
||||
members, uncovered = _decompose(self.__class__, self._value_)
|
||||
inverted_members = [
|
||||
m for m in self.__class__
|
||||
if m not in members and not m._value_ & self._value_
|
||||
]
|
||||
inverted = reduce(_or_, inverted_members, self.__class__(0))
|
||||
inverted = self.__class__(0)
|
||||
for m in self.__class__:
|
||||
if m not in members and not (m._value_ & self._value_):
|
||||
inverted = inverted | m
|
||||
return self.__class__(inverted)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue