469,332 Members | 7,058 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

python/C++ wrapper


Hi,

is there anyone here that calls C++ programs from python via swig? It
seems that there are a lot of different ways to do that. For me it
would be important that the original c++ code (which is available)
does not need to be changed and the whole compilation process (swig -
python.... g++....etc) is as simple as possible.

Does anyone have a running example of the following problem:

- A c++ program receives a 2D-matrix from python as input and gives a
2D-matrix as output back to python.

That's all! I would expect there should be someone who actually uses
swig for this kind of problem. If so, could you send me the code, that
would be great!

If it is important, I use linux and numpy.

Thanks,

Frank

Mar 14 '07 #1
7 3338
On 13 Mar 2007 21:55:55 -0700, Frank <su******@gmail.comwrote:
>
Hi,

is there anyone here that calls C++ programs from python via swig? It
seems that there are a lot of different ways to do that. For me it
would be important that the original c++ code (which is available)
does not need to be changed and the whole compilation process (swig -
python.... g++....etc) is as simple as possible.

Does anyone have a running example of the following problem:

- A c++ program receives a 2D-matrix from python as input and gives a
2D-matrix as output back to python.

That's all! I would expect there should be someone who actually uses
swig for this kind of problem. If so, could you send me the code, that
would be great!
If this is all you need, than may be you don't need to use any code
generator, but try
some other way: Boost.Python. Take a look on tutorials:
http://www.boost.org/libs/python/doc.../exposing.html
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
Mar 14 '07 #2
- A c++ program receives a 2D-matrix from python as input and gives a
2D-matrix as output back to python.
pyogre uses swig

ogre is a 3d realtime rendering engine written in c++ so there are
many matrix manipulation there and also pyogre does not modify the
original code

cgkit is a computer graphics toolkit written in c++ for python and it
uses boost-python and it uses matrices as well

if you want matrix manipulations in python then you may want to look
into numpy c api

Mar 14 '07 #3
On 14 Mar 2007 02:38:32 -0700, Szabolcs Nagy <ns*******@gmail.comwrote:
- A c++ program receives a 2D-matrix from python as input and gives a
2D-matrix as output back to python.

pyogre uses swig
Well, pyogre has few problems with maintenance, and new bindings to
Ogre engine was
created using Boost.Python( http://www.ogre3d.org/wiki/index.php/PyOgre )

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
Mar 14 '07 #4
Well, pyogre has few problems with maintenance, and new bindings to
Ogre engine was
created using Boost.Python( http://www.ogre3d.org/wiki/index.php/PyOgre )
oh
last time i played with pyogre they made a transition from boost to
swig :)
so they are back again at boost
(the problem with boost was the slow recompilation time with all the
gccxml parsing and a few other problems which maybe got resolved)
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
thanks for the info this py++ looks promising

Mar 14 '07 #5
Check out this example from NumPy. This would be the way sanctioned by
the scipy community, as you benefit from a large library of matrix
routines that you can use to prepare/postprocess the data.

http://www.scipy.org/Cookbook/SWIG_and_NumPy
Mar 14 '07 #6
En Wed, 14 Mar 2007 01:55:55 -0300, Frank <su******@gmail.comescribió:
is there anyone here that calls C++ programs from python via swig? It
I suggest you read the responses to your previous question; also search
the list archives for this month.

--
Gabriel Genellina

Mar 14 '07 #7
On Mar 14, 1:42 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
En Wed, 14 Mar 2007 01:55:55 -0300, Frank <super...@gmail.comescribió:
is there anyone here that calls C++ programs from python via swig? It

I suggest you read the responses to your previous question; also search
the list archives for this month.

--
Gabriel Genellina

Hi Gabriel,

and I suggest you read the question I asked precisely!

Frank

Mar 14 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Gary | last post: by
25 posts views Thread by Allenabethea | last post: by
4 posts views Thread by Edvard Majakari | last post: by
4 posts views Thread by Randall Hopper | last post: by
14 posts views Thread by Java and Swing | last post: by
2 posts views Thread by GinTon | last post: by
8 posts views Thread by Fett | last post: by
1 post views Thread by replysonika | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.