class Foo(object):

    def bar(self):
        return 5
f = Foo()
_f = dill.dumps(f)


class Foo(object):

    def bar(self, x):
        return x
g = Foo()
f_ = dill.loads(_f)
f_.bar()
g.bar(4)
Python pickling after changing a module's directory