[SciPy-user] C++ extensions

Prabhu Ramachandran prabhu_r at users.sf.net
Sat Oct 30 02:40:50 CDT 2004


>>>>> "DG" == David Grant <david.grant at telus.net> writes:

    DG> I looked at some Weave information, but that didn't help,
    DG> because I obviously can't run this in-line since it is many
    DG> files.

That seems like an incorrect assumption.  Weave will let you call any
function you want from within the inlined code.  From the information
you have provided, I assume you want to do something like this in
Python:

 a = Numeric.array(...)
 # Setup your matrix the way you want.

 call_c_code_that_does_stuff_to_array(a)

 # Continue work from Python...

So simply define call_c_code_that_does_stuff_to_array and write some
simple C++ code that does what you want.  This is definitely doable
from weave.  The question is what 'output' does your blackbox produce?
If its a number/array then they are easy to handle since weave will
let you do that.  When you call inline you can pass headers and link
to libraries that you have built.  So in theory you can build your
blackbox C++ code as a library, and call its functions from your
inlined code.

Of course, you can use SWIG or Boost.Python also.  But weave is still
an option.

cheers,
prabhu



More information about the SciPy-user mailing list