diff options
| author | Benjamin Peterson <benjamin@python.org> | 2014-05-03 20:22:00 -0400 |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2014-05-03 20:22:00 -0400 |
| commit | 4ce5f3f203c1c510bd1eff4d8fffea6198e40b4d (patch) | |
| tree | a7f54e7fe4a8652958375bf6bba0fdb517bbecf0 /Lib/copy.py | |
| parent | 98baa14109322ddae497bc8d823cc0bb1071b445 (diff) | |
| download | cpython-git-4ce5f3f203c1c510bd1eff4d8fffea6198e40b4d.tar.gz | |
improve idioms (closes #20642)
Patch by Claudiu Popa.
Diffstat (limited to 'Lib/copy.py')
| -rw-r--r-- | Lib/copy.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/copy.py b/Lib/copy.py index bb8840ed54..383609bc64 100644 --- a/Lib/copy.py +++ b/Lib/copy.py @@ -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: |
