mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
gh-100815: Normalize types
module usage in copy
module (#100816)
This commit is contained in:
parent
6746135b07
commit
951303fd85
1 changed files with 7 additions and 9 deletions
16
Lib/copy.py
16
Lib/copy.py
|
@ -101,13 +101,11 @@ _copy_dispatch = d = {}
|
||||||
|
|
||||||
def _copy_immutable(x):
|
def _copy_immutable(x):
|
||||||
return x
|
return x
|
||||||
for t in (type(None), int, float, bool, complex, str, tuple,
|
for t in (types.NoneType, int, float, bool, complex, str, tuple,
|
||||||
bytes, frozenset, type, range, slice, property,
|
bytes, frozenset, type, range, slice, property,
|
||||||
types.BuiltinFunctionType, type(Ellipsis), type(NotImplemented),
|
types.BuiltinFunctionType, types.EllipsisType,
|
||||||
types.FunctionType, weakref.ref):
|
types.NotImplementedType, types.FunctionType, types.CodeType,
|
||||||
d[t] = _copy_immutable
|
weakref.ref):
|
||||||
t = getattr(types, "CodeType", None)
|
|
||||||
if t is not None:
|
|
||||||
d[t] = _copy_immutable
|
d[t] = _copy_immutable
|
||||||
|
|
||||||
d[list] = list.copy
|
d[list] = list.copy
|
||||||
|
@ -173,9 +171,9 @@ _deepcopy_dispatch = d = {}
|
||||||
|
|
||||||
def _deepcopy_atomic(x, memo):
|
def _deepcopy_atomic(x, memo):
|
||||||
return x
|
return x
|
||||||
d[type(None)] = _deepcopy_atomic
|
d[types.NoneType] = _deepcopy_atomic
|
||||||
d[type(Ellipsis)] = _deepcopy_atomic
|
d[types.EllipsisType] = _deepcopy_atomic
|
||||||
d[type(NotImplemented)] = _deepcopy_atomic
|
d[types.NotImplementedType] = _deepcopy_atomic
|
||||||
d[int] = _deepcopy_atomic
|
d[int] = _deepcopy_atomic
|
||||||
d[float] = _deepcopy_atomic
|
d[float] = _deepcopy_atomic
|
||||||
d[bool] = _deepcopy_atomic
|
d[bool] = _deepcopy_atomic
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue