[C++-sig] Pickle python subclass of C++ interface

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sat Jul 17 18:32:07 CEST 2010

I think all you need to do is add
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:


----- Original Message ----

From: John Reid <j.reid at mail.cryst.bbk.ac.uk>
To: cplusplus-sig at python.org
Sent: Sat, July 17, 2010 2:17:12 AM
Subject: [C++-sig] Pickle python subclass of C++ interface


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


Cplusplus-sig mailing list
Cplusplus-sig at python.org

More information about the Cplusplus-sig mailing list