[PYTHON MATRIX-SIG] Re: SWIG, shadow classes, and NumPy

Tser-Yuan (Brian) Yang tbyang@icf.llnl.gov
Tue, 26 Nov 1996 12:37:00 -0800 (PST)


Since SWIG shadows a pointer with a Python string object, I think
the following can be useful:
In your C++ extension, implement a method 'Ptr_to_PyArray' that takes three
arguments, i.e., a pointer object for the data, a pointer object for
the shape, and a Python integer object for the number of dimension, and
returns a PyArray object of the Numeric module. This can be done with
the API 'PyArray_FromDimsAndData' in 'arrayobject.c'. An inverse method
'PyArray_to_Ptr' that takes a PyArray object and returns a tuple may
be very useful, too. 

I have been thinking about implementing these interface functions in
one of our applications, but I am putting it off because my current
project don't need them.
						Brian Yang


=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================