[petsc-users] petsc4py and high performance python

Aron Ahmadia aron.ahmadia at kaust.edu.sa
Thu May 17 11:14:25 CDT 2012


>
> - There are probably functions for which pure Python does not deliver the
> necessary speed (and PETSc probably does not provide the operations
> needed). I am researching how to rewrite such performance-critical parts in
> C/C++, and embed them in the Python code - using methods like scipy.weave
> or ctypes. [2]
>

There are a bunch of examples of doing this in the petsc4py repository in
demo/.  Start with Cython as your wrapper.


> - My question: Is it possible to share PETSc objects between the Python
> code and the embedded C/C++ code? For example, pass a PETSc.Mat via Python,
> operate on it with C/C++ and return the matrix to Python?
>

Yes.


> In general: Do you think my approach makes sense? I am new to PETSc and
> have not done high performance Python before, so I hope to learn from your
> answers, hints and criticism.
>

It depends on the project, but this is a reasonable path to consider.

A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120517/6757f27e/attachment.htm>


More information about the petsc-users mailing list