3

I want to pass numpy array of known size and type via SWIG to C function

# .py
data = numpy.arange( N , dtype=numpy.int32 )
external_c_function( data )

# .i
extern void external_c_function( int32_t* data );

# .c
void external_c_function( int32_t* data)
{
    // ...
}

Unfortunately, I will get an error:

TypeError: in method 'external_c_function', argument 1 of type 'int32_t *'

What is the easiest way to pass numpy array to SWIG?

1 Answer 1

2

You can use numpy.i. Just have a look at http://www.scipy.org/Cookbook/SWIG_NumPy_examples

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.