[Cython] how to initialize my c array in a quick way?
Stefan Behnel
stefan_ml at behnel.de
Fri Nov 7 10:14:27 CET 2008
Hi,
zhen_qing_he_456 wrote:
> if in my fuction i declare a c array like:
> cdef int a[5]
> now if want to initialize my array a, i can do follow:
> a[0] = 1
> a[1] = 10
> :
> :
> a[4] = 3
> the value to my array is not continuous. Is there a quicker way in Cython to do it like in c:
> a[5] = {1,3,28,5,3}
In the current Cython release candidate
http://cython.org/Cython-0.10.rc.tar.gz
you can do
def test():
cdef int* a = [1,2,3,4,5]
print a[0]
Apparently, this currently only works inside functions, but that should be
fixable.
Stefan
More information about the Cython-dev
mailing list