MCPcopy Index your code
hub / github.com/python/cpython / _keep_alive

Function _keep_alive

Lib/copy.py:227–241  ·  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

225del d
226
227def _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
243def _reconstruct(x, memo, func, args,
244 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…