I want to define initialized C-array in Pyrex, e.g. equivalent of:
unsigned char a[8] = {0,1,2,3,4,5,6,7};
What will be equivalent in Pyrex?
Just array is
cdef unsigned char a[8]
But how can I made it initialized with my values?
I want to define initialized C-array in Pyrex, e.g. equivalent of:
unsigned char a[8] = {0,1,2,3,4,5,6,7};
What will be equivalent in Pyrex?
Just array is
cdef unsigned char a[8]
But how can I made it initialized with my values?
In Cython, Pyrex's successor, this feature was added over a year a go to fix this feature request, so for example the following works in Cython now:
cdef double a[] = [0.5, 0.3, 0.1, 0.1]
However, Pyrex's development is proceeding much more slowly (which is why Cython was forked years ago by developers rarin' for faster action), so I doubt it's picked up this feature (though you can try, esp. if you're using the very latest release of Pyrex, 0.9.8.6).
If Pyrex isn't giving you the features you want, may I suggest switching to Cython instead? Most Pyrex code should just recompile smoothly in Cython, and you do get the extra features this way.