473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 3425
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JW | last post by:
Hi, Below is a description of what I would like to do. Would someone tell me if it is possible and if so, how? I have an array (presumably 'large') that is mallocced in a C function and its...
5
by: Gary | last post by:
Hi- I've been searching the web for a while and I've been unable to find a way to access c data objects in python without using SWIG. I can do methods just fine but I can't access variables. ...
25
by: Allenabethea | last post by:
Jython is 100% java coded python. Python objects work with javacompilers and Virtual machines. I am a hobby programmer so the technical reasons are probably beyond me... Why is python...
4
by: Edvard Majakari | last post by:
Hi, I was wondering what would be the most elegant way for creating a Python class wrapper for a command line utility, which takes three types of arguments: 1. options with values (--foo=bar)...
4
by: Randall Hopper | last post by:
What is the correct way to propagate exceptions from Python callbacks? When I do this: Python -> C++ -> Python Callback (example attached) an exception raised in the callback doesn't make it...
14
by: Java and Swing | last post by:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) { // this will store the result in a Python object PyObject *finalResult; // get arguments from Python char *result = 0; char *in=...
2
by: GinTon | last post by:
EyeDB is a free ODBMS based on the ODMG 3 specification with programming interfaces for C++ and Java. It is very powerfull, mature, safe and stable. In fact, it was developed in 1992 for the Genome...
3
by: Daniel Fetchinson | last post by:
Does Python 2.5.2's embedded SQLite support full text searching? Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it...
8
by: Fett | last post by:
I am trying to find a wrapper to do linear programming within python. I am using an ubuntu machine and I have apt-get'd lp_solve, which works just fine. If someone knows of a wrapper that will work...
1
by: replysonika | last post by:
Hello, I run a Java app with subprocess from Python script. This python script is called from another Python Wrapper. python = subprocess.Popen(, stdout=subprocess.PIPE,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.