Hey everyone:
I'm just getting started with Cython, I am trying to convert some Mathematica code to code that is compatible with cython/sage. I am familiar with python and reasonably familiar with C (though it has been a while). I'm a bit confused with some of the syntax that is used when defining arrays in cython. I have seen this syntax is one of the tutorials:
from cpython cimport array
import array
cdef array.array a = array.array('i', [1, 2, 3])
cdef int[:] ca = a
So, from my understanding, the array.array creates a c array. Then, what is the purpose of the "int[:] ca = c" part of the code? is this to allow for easier/safer access to the original array? Why is it not possible to simply initialize my array with that line, instead of having to initialize it as an "array.array"? On stackoverflow, I also saw the following:
cdef int mom2calc[3]
mom2calc[:] = [1, 2, 3]
What is the difference between what this does and what the earlier code did? Also, from what I've read, much of the speed gain in cython comes from having static typed variables. So if I were to predefine a variable as a list, would that give a speed boost similar to the above? Perhaps something like:
Thank you!