MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _keep_alive

Function _keep_alive

tools/python-3.11.9-amd64/Lib/copy.py:243–257  ·  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

(x, memo)

Source from the content-addressed store, hash-verified

241del d
242
243def _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
259def _reconstruct(x, memo, func, args,
260 state=None, listiter=None, dictiter=None,

Callers 1

deepcopyFunction · 0.85

Calls 2

idFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected