Why can't instance methods be pickled?
effbot at telia.com
Sun Oct 8 16:23:48 CEST 2000
> Is there a fundamental reason why instance method pickling is not
quoting the pickle docs:
"Note that when class instances are pickled, their class's code
and data are not pickled along with them. Only the instance
data are pickled. This is done on purpose, so you can fix bugs
in a class or add methods and still load objects that were
created with an earlier version of the class."
> Has anyone written code to solve this problem?
What do you want pickle to do in this case?
If you want to pickle the actual code, you can register a method
pickler using copy_reg (use marshal to serialize the code object).
If you want to ignore the function pointer, implement __getstate__
and __setstate__ methods in your class (see the pickle docs for
<!-- (the eff-bot guide to) the standard python library:
More information about the Python-list