What type for a mpi4py communicator in python?

Viewed 100

I am using mpi4py to parallelize my code, I have this kind of function:

def do_something(some_integer: int, comm) -> None:
    ...

Where the comm argument is for an mpi communicator like the following:

from mpi4py import MPI
comm = MPI.COMM_WORLD

I want to use explicit typing for my functions and it is not clear to me what should be the type of the comm argument, i.e. what should come after comm: ?

1 Answers

Accordingly the MPI documentation that type should be:

mpi4py.MPI.Intracomm

So try it out with

def do_something(some_integer: int, comm: mpi4py.MPI.Intracomm) -> None:
Related