mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
parent
98baa14109
commit
4ce5f3f203
1 changed files with 3 additions and 5 deletions
|
|
@ -221,17 +221,15 @@ def _deepcopy_list(x, memo):
|
||||||
d[list] = _deepcopy_list
|
d[list] = _deepcopy_list
|
||||||
|
|
||||||
def _deepcopy_tuple(x, memo):
|
def _deepcopy_tuple(x, memo):
|
||||||
y = []
|
y = [deepcopy(a, memo) for a in x]
|
||||||
for a in x:
|
|
||||||
y.append(deepcopy(a, memo))
|
|
||||||
# We're not going to put the tuple in the memo, but it's still important we
|
# We're not going to put the tuple in the memo, but it's still important we
|
||||||
# check for it, in case the tuple contains recursive mutable structures.
|
# check for it, in case the tuple contains recursive mutable structures.
|
||||||
try:
|
try:
|
||||||
return memo[id(x)]
|
return memo[id(x)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
for i in range(len(x)):
|
for k, j in zip(x, y):
|
||||||
if x[i] is not y[i]:
|
if k is not j:
|
||||||
y = tuple(y)
|
y = tuple(y)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue