| 208 | d[list] = _deepcopy_list |
| 209 | |
| 210 | def _deepcopy_tuple(x, memo, deepcopy=deepcopy): |
| 211 | y = [deepcopy(a, memo) for a in x] |
| 212 | # We're not going to put the tuple in the memo, but it's still important we |
| 213 | # check for it, in case the tuple contains recursive mutable structures. |
| 214 | try: |
| 215 | return memo[id(x)] |
| 216 | except KeyError: |
| 217 | pass |
| 218 | for k, j in zip(x, y): |
| 219 | if k is not j: |
| 220 | y = tuple(y) |
| 221 | break |
| 222 | else: |
| 223 | y = x |
| 224 | return y |
| 225 | d[tuple] = _deepcopy_tuple |
| 226 | |
| 227 | def _deepcopy_dict(x, memo, deepcopy=deepcopy): |