[Numpy-discussion] Array Protocol change for Python 2.6

Andrew Straw strawman at astraw.com
Fri Jun 9 15:51:57 CDT 2006


Travis Oliphant wrote:

> Andrew Straw wrote:
>
>> On the one hand, I feel we should keep __array_struct__ behaving 
>> exactly as it is now. There's already lots of code that uses it, and 
>> it's tremendously useful despite (because of?) it's simplicity. For 
>> these of use cases, the __array_descr__ information has already 
>> proven unnecessary. I must say that I, and probably others, thought 
>> that __array_struct__ would be future-proof. Although the magnitude 
>> of the proposed change to add this information to the C-struct 
>> PyArrayInterface is minor, it still breaks code in the wild.
>>
> I don't see how it breaks any code in the wild to add an additional 
> member to the C-struct.   We could easily handle it in new code with a 
> flag setting (like Python uses).     The only possible problem is 
> looking for it when it is not there.

Ahh, thanks for clarifying. Let me paraphrase to make sure I got it 
right: given a C-struct "inter" of type PyArrayInterface, if and only if 
((inter.flags & HAS_ARRAY_DESCR) == HAS_ARRAY_DESCR) inter could safely 
be cast as PyArrayInterfaceWithArrayDescr and thus expose a new member. 
This does seem to avoid all the issues and maintain backwards 
compatibility. I guess the only potential complaint is that it's a 
little C trick which might be unpalatable to the core Python devs, but 
it doesn't seem egregious to me.

If I do understand this issue, I'm +1 for the above scheme provided the 
core Python devs don't mind.

Cheers!
Andrew




More information about the Numpy-discussion mailing list