def make_instancemethod(function, instance): return new.instancemethod(function.im_func, instance, instance.__class__)