On 09/30/2009 11:48 PM, Ralf W. Grosse-Kunstleve wrote:
lvalue_from_pytype only works for passing by value or const 
references/pointers, but that seems to match your case,
since you MPI_Comm is passed by value to your sayhello().

However, wrapping extern "C" isn't portable, AFAIK. You'll need a thin C++ 
wrapper for each of the C functions.
Yes. I think you are right. I'm going to try that now.
Did you consider writing a thin object-oriented wrapper around the raw MPI 
interfaces? Then it should be very straightforward to bind the wrapper with 
Boost.Python, and you'll have a more intuitive Python interface.
E.g. make a class that owns MPI_Comm, passed as boost::python::object, and then 
give it a .sayhello() method using the comm data member.

It's more complicated than that. mpi4py provides a nice object-oriented wrapper on the Python side. The mpi4py wrapper is based on the "standard" MPI C++ bindings. Unfortunately, older versions of MPI don't support the C++ bindings and MPI has decided that the bindings will be dropped in the future, so I really don't want to start using them now. I think I will do as you suggest and just write very thin wrappers around the C interfaces.

Thanks for your help.

--Jim Amundson

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to