Dag Sverre Seljebotn wrote: > Robert Bradshaw wrote: > >> cdef double *a = [0.5, 0.3, 0.1, 0.1] > >>Note that it is still allocated on the stack, but a pointer type is >>needed as arrays aren't lvalues. > > It looks a bit confusing...
I think it looks confusing, too. Is 'a' a real pointer here? I.e. can you assign a different pointer value to it later? If so, then it's not obvious where the memory for the initial value is being allocated. A C person would probably guess that it's either statically allocated (by analogy with char *p = "literal") or heap allocated. Allocating it on the stack is neither a C-like nor a Python-like thing to do. It would be better if it were written as cdef double a[] = [0.5, 0.3, 0.1, 0.1] the same as a statically initialized array. The fact that arrays aren't lvalues isn't relevant, because this isn't an assignment, it's a specification of an initial value. -- Greg _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
