Commit 4ce5f3f2 authored by Benjamin Peterson's avatar Benjamin Peterson

improve idioms (closes #20642)

Patch by Claudiu Popa.
parent 98baa141
......@@ -221,17 +221,15 @@ def _deepcopy_list(x, memo):
d[list] = _deepcopy_list
def _deepcopy_tuple(x, memo):
y = []
for a in x:
y.append(deepcopy(a, memo))
y = [deepcopy(a, memo) for a in x]
# 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.
try:
return memo[id(x)]
except KeyError:
pass
for i in range(len(x)):
if x[i] is not y[i]:
for k, j in zip(x, y):
if k is not j:
y = tuple(y)
break
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment