[C++-sig] Extended python system needs access to cPickle in c++
William Ladwig
wladwig at wdtinc.com
Tue May 5 16:53:28 CEST 2009
You can import python modules in C++ using the import function. See here:
http://www.boost.org/doc/libs/1_39_0/libs/python/doc/v2/import.html
You can also make your C++ extension classes 'pickleable' using boost python's pickle suite:
http://www.boost.org/doc/libs/1_39_0/libs/python/doc/v2/pickle.html
Bill
-----Original Message-----
From: cplusplus-sig-bounces+wladwig=wdtinc.com at python.org [mailto:cplusplus-sig-bounces+wladwig=wdtinc.com at python.org] On Behalf Of Simon Pickles
Sent: Tuesday, May 05, 2009 4:29 AM
To: cplusplus-sig at python.org
Subject: [C++-sig] Extended python system needs access to cPickle in c++
Hi,
I have an app with a python core, then c++ extension modules.
I'd like to be able to use cPickle to pack structures, especially
boost::python::tuples, in c++.
Is there a way I can expose a python module in the c++ extensions?
I thought about passing a module as an arg to a c++ function, as a
boost::python::object:
// cModule
void DoStuff(object pickleModule)
{
tuple t = make_tuple("Spam",42);
object pickleDumps = pickleModule.attr("dumps");
object s = pickleDumps(t);
// Send s to other process
}
# python
import cModule
import cPickle
cModule.DoStuff(cPickle)
#
Am I barking up the wrong tree?
Many thanks
Simon
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
More information about the Cplusplus-sig
mailing list