[Python-checkins] cpython: improve idioms (closes #20642)
benjamin.peterson
python-checkins at python.org
Sun May 4 02:22:38 CEST 2014
http://hg.python.org/cpython/rev/0df3004581fe
changeset: 90552:0df3004581fe
user: Benjamin Peterson <benjamin at python.org>
date: Sat May 03 20:22:00 2014 -0400
summary:
improve idioms (closes #20642)
Patch by Claudiu Popa.
files:
Lib/copy.py | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/Lib/copy.py b/Lib/copy.py
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -221,17 +221,15 @@
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:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list