[Numpy-discussion] Accessing a Numeric 'c' array from numarray]
falted at openlc.org
Mon Jan 20 04:17:03 EST 2003
A Dissabte 18 Gener 2003 21:12, Todd Miller va escriure:
> >By the way, is it safe to assume that CharArray objects are contiguous? or
> Mostly no. Each fixed length element is stored as a contiguous
> sequence of bytes. Anything goes for the rest, so you need to look at
> the strides arrays and byteoffset.
> >The same question goes for RecArray objects.
> No. It's possible to select every 10th record, for instance, in a
> slice. I believe the resulting decimated array would be a discontiguous
> view of the original.
> >Or it is always
> >convenient to check with iscontiguous() method if they are or not?.
> I'm not even certain the method works correctly for chararray and
Well, during my tests with numarray 0.4, iscontiguous() seems to work well,
both for chararrays and recarrays.
> In both cases, I think I'd just forget about
> contiguity and use the strides arrays.
Yeah, but I still want to use iscontiguous() method just to speed-up a bit
> You might argue that records contain
> byteswapped and misaligned fields. I don't have an immediate answer to
Exactly, I am pondering how to deal with HDF5 objects coming from machines
with a different endianess (misalignment is not a problem in my case) than
the local machine. But I think I can manage that by creating recarrays
buffers with the byteorder parameter set appropriately during the HDF5 table
reads. Then, all the data can be read correctly because numarray will
byteswap the data whenever this recarray will be accessed.
Moreover, if this object is to be used frequently, I can speed-up the access
to this recarray by byteswapping the columns (as arrays) using their
byteswap() method. In the future it would be nice to provide a generica
byteswap method for recarrays.
More information about the NumPy-Discussion