MCPcopy Index your code
hub / github.com/RustPython/RustPython / _keep_alive

Function _keep_alive

Lib/copy.py:212–226  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

210del d
211
212def _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
228def _reconstruct(x, memo, func, args,
229 state=None, listiter=None, dictiter=None,

Callers 1

deepcopyFunction · 0.85

Calls 2

idFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected