[petsc-users] petsc4py and mixed python/c++ code

Matthew Knepley knepley at gmail.com
Mon Nov 11 14:24:10 CST 2013


On Mon, Nov 11, 2013 at 1:46 PM, Geoffrey Irving <irving at naml.us> wrote:

> I'm revamping Otherlab's use of petsc, and taking another look at
> petsc4py as part of that.  Previously we rolled our own Python
> bindings, but it'd be great to not have to do that.
>
> However, our usage would involve writing new C/C++ functions which
> take petsc types as arguments, and then exposing these new functions
> to python.  Is there a way to do this if the petsc4py bindings are
> written in Cython?


1) Lisandro is the expert

2) C is fairly trivial using Cython

3) If you use a bunch of C++ stuff, at least when I evaluated things last
time,
     Cython was fairly hard to manage (esp. templates). However, SWIG
     worked alright. I have never tried mixing SWIG and Cython, but I would
     think its possible, since all you have to do is pull out a wrapped
pointer.

I have never seen mixed language programming be more efficient for a
developing library. Wrapping stable, debugged libraries makes a lot of
sense,
and can really speed up development. Wrapping libraries you are still
playing
with makes interfaces changes harder, and debugging a nightmare.

   Matt


>
> Geoffrey
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131111/ed57e1cf/attachment.html>


More information about the petsc-users mailing list