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
(x, memo)
| 241 | del d |
| 242 | |
| 243 | def _keep_alive(x, memo): |
| 244 | """Keeps a reference to the object x in the memo. |
| 245 | |
| 246 | Because we remember objects by their id, we have |
| 247 | to assure that possibly temporary objects are kept |
| 248 | alive by referencing them. |
| 249 | We store a reference at the id of the memo, which should |
| 250 | normally not be used unless someone tries to deepcopy |
| 251 | the memo itself... |
| 252 | """ |
| 253 | try: |
| 254 | memo[id(memo)].append(x) |
| 255 | except KeyError: |
| 256 | # aha, this is the first one :-) |
| 257 | memo[id(memo)]=[x] |
| 258 | |
| 259 | def _reconstruct(x, memo, func, args, |
| 260 | state=None, listiter=None, dictiter=None, |