[Numpy-discussion] Performance of the array protocol

Travis Oliphant oliphant at ee.byu.edu
Tue Nov 1 12:39:41 CST 2005


David M. Cooke wrote:

>"C
>
>I had posted an idea before:
>
>http://thread.gmane.org/gmane.comp.python.numeric.general/2159
>
>It would still be one attribute lookup, but then everything would be
>C-based from there on.
>  
>
Thanks for reminding us of your idea again.   This is a very good idea, 
that I think we could add.   My only question is should Py_LONG_LONG be 
used or Py_intptr_t?   Since the array has to be in memory anyway there 
does not seem any advantage to using Py_LONG_LONG.

I also think a flags member of the structure is useful along with a 
typestr instead of typecode.   I would say the C-struct should look 
like.  We could push to get something like this in Python core, I think, 
so this Array_Interface header was available to everybody.

typedef struct {
    int nd;
    char typekind;
    int itemsize;
    int flags;
    Py_intptr_t *shape;
    Py_intptr_t *strides;
    Py_intptr_t offset;
    void *data;
} PyArray_Interface








More information about the Numpy-discussion mailing list