On Oct 11, 2008, at 12:24 AM, Greg Ewing wrote:
> Robert Bradshaw wrote:
>
>> It's on the stack, just like literals.
>
> What do you mean, "just like literals"? What literal
> is ever allocated on the stack?
Array literals are allocated on the stack.
>
>> However, one can write
>>
>> def foo(x, y):
>> cdef double* a
>> if x:
>> a = [1,2,3,x]
>> else:
>> a = [1,2,3,y]
>
> Now I'm *really* confused. What the heck does that do?
> Can you provide a C translation?
Sure. I'm ignoring the implicit conversions that happen for clarity...
double[4] tmp1;
double[4] tmp2;
if (x) {
tmp1[0] = 1
tmp1[1] = 2
tmp1[2] = 3
tmp1[3] = x
a = tmp1
}
else {
tmp2[0] = 1
tmp2[1] = 2
tmp2[2] = 3
tmp2[3] = y
a = tmp2
}
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev