[Numpy-discussion] Questions about the array interface.
xscottg at yahoo.com
Thu Apr 7 04:52:11 CDT 2005
--- "David M. Cooke" <cookedm at physics.mcmaster.ca> wrote:
> > Good point, but a pain. Maybe they should be required, that way I
> > don't have to first check for the presence of '<' or '>', then check
> > if they have the right value.
> I'll second this. Pulling out more Python Zen: Explicit is better than
> This is a good point; all good protocols embed a version somewhere.
> Not doing it now could lead to grief/pain later.
> I'd suggest adding to __array_data__: If __array_data__ is None, then
> the array is implementing a newer version of the interface, and you'd
> either need to support that (maybe the new version uses
> __array_data2__ or something), or use the sequence protocol on the
> original object. The sequence protocol should definitely be safe all
> the time, whereas the buffer protocol may not. (Put it this way: I
> understand the sequence protocol well, but not the buffer one :-)
> That would also be a good argument for it existing, I think.
> Alternatively, we could add an __array_version__ attribute (required
> to exist, required to check) which is set to 1 for this protocol.
I like this, although I think having __array_data__ return None is
confusing. 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 on...
More information about the Numpy-discussion