By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

Calling cpp from python/SWIG

P: n/a
Hi,

I have the following problem:

I want to parse an array M1 from python to a cpp function fct which
returns an array M2.

How can I do this best? Is SWIG appropriate or is there something
else?

If someone could give some code example or a link to a page with
examples, that would be great!

Thanks to all!

Frank

Mar 13 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
En Tue, 13 Mar 2007 03:33:43 -0300, Frank <su******@gmail.comescribió:
I want to parse an array M1 from python to a cpp function fct which
returns an array M2.

How can I do this best? Is SWIG appropriate or is there something
else?
If you're going to call a single function, declare it with extern "C" (or
write a wrapper function) and use ctypes from Python.
Try to keep the memory allocation in Python: instead of returning another
array, make the function use the *same* input array, or give it -from
Python- a previously allocated array.
ctypes comes with Python 2.5, and you can download and install it for
previous versions too.

--
Gabriel Genellina

Mar 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.