def _instance_setitem(self, k, v):
    print('old setitem')

def new_setitem(self, k, v):
    print('new setitem')
f[0] = 0
f._instance_setitem = types.MethodType(new_setitem, f, Foo)
f[0] = 0
How to dynamically override __setitem__? (no subclass)