Ralf W. Grosse-Kunstleve wrote:
I think all you need to do is add
.enable_pickling()
to your Boost.Python wrapper and
def __getinitargs__(self):
return (x,y,z)
to your subclass.
You could also use __getstate__, __setstate__, but I'd try to work with
just __getinitargs__ first.
See also:
http://www.boost.org/doc/libs/1_43_0/libs/python/doc/v2/pickle.html
Ok I'll give that a whirl. I was hoping to avoid doing __getinitargs__()
for each subclass as I have quite a few of them. If I didn't have a C++
base class then the pickling would just work as is. There's no way I can
get back to that sort of situation with the C++ base class is there?
Thanks,
John.
----- Original Message ----
From: John Reid <j.r...@mail.cryst.bbk.ac.uk>
To: cplusplus-sig@python.org
Sent: Sat, July 17, 2010 2:17:12 AM
Subject: [C++-sig] Pickle python subclass of C++ interface
Hi,
I'm using boost.python. I want to pickle some python subclasses of a C++ base.
The C++ base does not have any state, it is just an interface. Is there an easy
way to ask the python pickling machinery to ignore the C++ base? I'm not sure if
I should use the boost.python pickling support or go directly down the route
described at
http://docs.python.org/library/pickle.html#pickling-and-unpickling-extension-types
Thanks,
John.
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig