[Numpy-discussion] Fixing PyArray_Descr flags member size, ABI vs pickling issue

David Cournapeau cournape@gmail....
Tue Mar 6 10:07:31 CST 2012

On Tue, Mar 6, 2012 at 6:20 AM, Robert Kern <robert.kern@gmail.com> wrote:
> On Tue, Mar 6, 2012 at 03:53, David Cournapeau <cournape@gmail.com> wrote:
>> Hi,
>> This is following the discussion on bug
>> http://projects.scipy.org/numpy/ticket/2017
>> Essentially, there is a discrepency between the actual type of the
>> flags member in the dtype C structure (char) and how it is declared in
>> the descriptor table (T_INT). The problem is that we are damned if we
>> fix it, damned if we are not:
>>  - fixing T_INT to T_BYTE. flag in python is now fixed, but it breaks
>> pickled numpy arrays
> Is the problem that T_BYTE returns a single-item string?

Yes (although it is actually what we want, instead of an int).

> My handwrapping skills are rusty (Cython has blissfully eradicated this
> from my memory), but aren't these T_INT/T_BYTE things just convenient
> shortcuts for exposing C struct members as Python attributes? Couldn't
> we just write a full getter function for returning the correct value,
> just returned as a Python int instead of a str.

You're right, I did not think about this solution. That's certainly
better than the two I suggested.



More information about the NumPy-Discussion mailing list