I'd like to do exactly this in Cython:
cdef int shiftIndexes[] = [1,-1, 0, 2,-1, -1, 4, 0, -1, 8, 1, -1, 16, 1, 0, 32, 1, 1, 64, 0, 1, 128, -1, 1]
I've seen a few references in fixed bug reports and old email lists that static array functionality exists in Cython, but I can't find anty examples and this particular example gives me a syntax error: Syntax error in C variable declaration
Is it possible to make static C arrays with Cython?
Since their size isn't set until runtime, variable-length arrays may not be declared at file scope or with the static keyword, nor can they be declared with an initializer list.
Use pointer notation instead:
cdef int *shiftIndexes = [1,-1, 0, 2,-1, -1, 4, 0, -1, 8, 1, -1, 16, 1, 0, 32, 1, 1, 64, 0, 1, 128, -1, 1]
And it will work like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With