[Cython] array assignment
Robert Bradshaw
robertwb at math.washington.edu
Sun Oct 12 03:01:29 CEST 2008
On Oct 11, 2008, at 5:10 PM, Greg Ewing wrote:
> Robert Bradshaw wrote:
>> Yes, the
>> arrays as they are now have a few warts (like using them in loops)
>> but I think it's too useful to disable altogether.
>
> You could get the same effect in a much less misleading
> way using
>
> cdef int data[] = [1, 2, 3, 4]
> cdef int *a = data
>
> Now it's perfectly clear that a is pointing to something
> stack-allocated. EIBTI.
Yes, but the whole point was to be more concise (specifically, better
than setting the elements one by one, but even this is somewhat
redundant). The reason I did it the way I did was because
cdef foo = x
gets translated to
cdef foo
foo = x
and so disallowing assignments in one place, but not in another, and
allowing assignments to array types just once, etc. was a whole lot
more complicated that what I wanted to deal with at the time.
Eventually we will get there.
- Robert
More information about the Cython-dev
mailing list