A better option is to put the MPI and PETSc imports in a separate file and import from there.  I don't quite understand, however, why we need to import petsc from core_types, rather than just directly from petsc4py.  Can you explain?