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)
| 210 | del d |
| 211 | |
| 212 | def _keep_alive(x, memo): |
| 213 | """Keeps a reference to the object x in the memo. |
| 214 | |
| 215 | Because we remember objects by their id, we have |
| 216 | to assure that possibly temporary objects are kept |
| 217 | alive by referencing them. |
| 218 | We store a reference at the id of the memo, which should |
| 219 | normally not be used unless someone tries to deepcopy |
| 220 | the memo itself... |
| 221 | """ |
| 222 | try: |
| 223 | memo[id(memo)].append(x) |
| 224 | except KeyError: |
| 225 | # aha, this is the first one :-) |
| 226 | memo[id(memo)]=[x] |
| 227 | |
| 228 | def _reconstruct(x, memo, func, args, |
| 229 | state=None, listiter=None, dictiter=None, |