MCPcopy Index your code
hub / github.com/ipython/ipython / update_instances

Function update_instances

IPython/extensions/autoreload.py:368–377  ·  view source on GitHub ↗

Use garbage collector to find all instances that refer to the old class definition and update their __class__ to point to the new class definition

(old, new)

Source from the content-addressed store, hash-verified

366
367
368def update_instances(old, new):
369 """Use garbage collector to find all instances that refer to the old
370 class definition and update their __class__ to point to the new class
371 definition"""
372
373 refs = gc.get_referrers(old)
374
375 for ref in refs:
376 if type(ref) is old:
377 object.__setattr__(ref, "__class__", new)
378
379
380def update_class(old, new):

Callers 1

update_classFunction · 0.85

Calls 1

__setattr__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…