Last active
January 4, 2016 01:49
-
-
Save graingert/8550600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
def super_patch(old_obj, new_obj): | |
if old_obj is new_obj: | |
return | |
gc.collect() | |
for referrer_obj in gc.get_referrers(old_obj): | |
if hasattr(referrer_obj, "iteritems"): | |
for key, value in referrer_obj.iteritems(): | |
if value is old_obj: | |
referrer_obj[key] = new_obj |
Author
graingert
commented
Jan 22, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment