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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
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.