[C++-sig] boost::python::object referencing c++ object
Bjorn Pettersen
BPettersen at NAREX.com
Fri Jan 3 20:43:29 CET 2003
I've got the following code to assign a wrapped object to a Python
variable:
template <class T>
void set(const std::string& name, const T& value) {
PyObject* key = PyString_FromString(name.c_str());
object val(value);
PyDict_SetItem(interpreter()->mainmodule(), key, val.ptr());
Py_DECREF(key);
}
and I'd like to be able to set() a variable to a c++ object, then later
mutate the object and have the changes visible to Python. I haven't
traced through the code completely, but it looks like the object ctor
makes a copy(?) Is there any way to accomplish what I'd like to do?
-- bjorn
More information about the Cplusplus-sig
mailing list