Keeps a reference to the object x in the memo. Because we remember objects by their id, we have to assure that possibly temporary objects are kept alive by referencing them. We store a reference at the id of the memo, which should normally not be used unless someone tries to dee
(x, memo)
| 225 | del d |
| 226 | |
| 227 | def _keep_alive(x, memo): |
| 228 | """Keeps a reference to the object x in the memo. |
| 229 | |
| 230 | Because we remember objects by their id, we have |
| 231 | to assure that possibly temporary objects are kept |
| 232 | alive by referencing them. |
| 233 | We store a reference at the id of the memo, which should |
| 234 | normally not be used unless someone tries to deepcopy |
| 235 | the memo itself... |
| 236 | """ |
| 237 | try: |
| 238 | memo[id(memo)].append(x) |
| 239 | except KeyError: |
| 240 | # aha, this is the first one :-) |
| 241 | memo[id(memo)]=[x] |
| 242 | |
| 243 | def _reconstruct(x, memo, func, args, |
| 244 | state=None, listiter=None, dictiter=None, |