Passing back an array from an extension module?

Bob Greschke bob at passcal.nmt.edu
Fri Jun 8 11:28:33 EDT 2001


Is this a job for NumPy?

I have a C extension function that malloc()s an array of int32s, calls
another C function which reads/decodes a file of data and fills in the
array.  Then I need to pass that back to the Python side for graphing
the values.  I initially thought I could just create a tuple and pass
that back, since nothing is going to be done with the values except to
draw a graph, but there is the possibility of there being 16,000,000
data points...that makes for a slightly large statement, doesn't it?
It doesn't look like I can do this with arrays in stock Python, but it
does look like I can do it with the NumPy arrays.  Is that correct?

Now what about Py_DECREF, INCREF and all of that stuff in these
situations?  I read through a number of posts on dejagoogle that were
talking about this, but they only confused me more. :-)

Thanks!

Bob






More information about the Python-list mailing list