class Foo(object):

    def bar(self, x):
        return x + self.y
y = 1
f = Foo()
_Foo = dill.dumps(Foo)
_f = dill.dumps(f)


class Foo(object):

    def bar(self, x):
        pass
How to use dill to serialize a class definition?