[Numpy-discussion] Questions about the array interface.
Chris.Barker at noaa.gov
Thu Apr 7 11:38:43 EDT 2005
Scott Gilbert wrote:
> I think __array_version__ (or __array_protocol__?) is the
> better choice. How about have it optional and default to 1? If it's
> present and greater than 1 then it means there is something new going
Again, I'm uncomfortable with something that I have to check being
optional. If it is, we're encouraging people to not check it, and that'
a recipe for bugs later on down the road.
> Everyone seems to think that an offset is so weird. I haven't looked at
> the internals of Numeric/scipy.base in a while so maybe it doesn't apply
> there. However, if you subscript an array and return a view to the data,
> you need an offset or you need to create a new buffer that encodes the
> offset for you.
> I guess all I'm saying is that I wouldn't assume the offset is zero...
Good point. All the more reason to have the offset be mandatory.
> The fact that a lot of these attributes are optional should be hidden in
> helper functions like those in Travis's array_interface.py module, or a
> C/C++ include file (with inline functions).
Yes, if there is a C/C++ version of all these helper functions, I'll be
a lot happier. And you're right, the same information should not be
encoded in two places, so my "iscontiguous" attribute should be a helper
function or maybe a method.
> In a short while, you shouldn't have to check any __array_metadata__
> attributes directly. There should even be a helper function for getting
> the array elements.
Cool. How would that work? A C++ iterator? I"m thinking not, as this is
all C, no?
> It wouldn't be a horrible mistake to have all the attributes be
> but it doesn't get array consumes any benefit that they can't get from a
> well written helper library, and it does add some burden to array
Hardly any. I'm assuming that there will be a base_array class that can
be used as a base class or mixin, so it wouldn't be any work at all to
have a full set of attributes with defaults. It would take up a little
bit of memory. I'm assuming that the whole point of this is to support
large datasets, but maybe that isn't a valid assumption, After all,
small array support has turned out to be very important for Numeric.
As a rule of thumb, I think there will be consumers of arrays that
producers, so I'd rather make it easy on the consumers that the
producers, if we need to make such a trade off. Maybe I'm biased,
because I'm a consumer.
Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion