[Numpy-discussion] Accessing a Numeric 'c' array from numarray]

Francesc Alted falted at openlc.org
Sat Jan 18 10:18:02 CST 2003

A Dissabte 18 Gener 2003 17:41, Todd Miller va escriure:
> >I just want to access the buffer data, and the shape of this object from C
> >(well, I'm actually using Pyrex, but I think this is not important). Is
> > that possible by only using numarray C calls?
> Look at Lib/chararray.py and Src/_chararraymodule.c.
> If you can handle using a CharArray or RawCharArray, try:
> 1. call NA_updateDataPtr( array ) to refresh the data buffer pointer in
> the PyArrayObject.  Even _chararraymodule.c doesn't do this right yet.
> 2. call NA_OFFSETDATA(array) to add the byteoffset to the pointer.
> 3. shape, strides, and itemsize should be directly accessible from the
> PyArrayObject.

Ok. I'll try to do that.

> CharArray has some extra stripping and padding semantics; these are lazy
> and hence absent without extra care in C.  RawCharArray has none.

By the way, is it safe to assume that CharArray objects are contiguous? or
RawCharArray?. The same question goes for RecArray objects. Or it is always
convenient to check with iscontiguous() method if they are or not?. In case
these objects can be non-contiguous, I guess there's still not a function
like NA_InputArray that works with CharArray or RecArray objects in order to
obtain well-behaved objects. Is that true?

I think it would be possible to me to include support for numarray objects
in next release of PyTables. Thanks!,

Francesc Alted

More information about the Numpy-discussion mailing list