How to pass an MPI communicator from python to C via cython?
I am trying to wrap a C function taking an MPI_Comm communicator handle as a parameter via cython. As a result, I want to be able to call the function from python, passing it an mpi4py.MPI.Comm object. What I am wondering is, how to make the conversion from mpi4py.MPI.Comm to MPI_Comm . To demonstrate, I use a simple "Hello World!"-type function: helloworld.h : #ifndef HELLOWORLD #define HELLOWORLD #include <mpi.h> void sayhello(MPI_Comm comm); #endif helloworld.c : #include <stdio.h> #include "helloworld.h" void sayhello(MPI_Comm comm){ int size, rank; MPI_Comm_size(comm, &size); MPI_Comm