[Cython] array assignment

Dag Sverre Seljebotn dagss at student.matnat.uio.no
Fri Oct 3 12:44:03 CEST 2008


Dag Sverre Seljebotn wrote:
> A problem is with mutability though, if it is done using C static 
> allocation. I.e.:
> 
> def f(x):
>      cdef int a[3] = [1,2,3]
>      if x: a[2] = 1
>      print a[2]
> 
> f(True) # prints 1...
> f(False) # likely prints 1 too!
> 
> This is consistent with what you expect from C but very contrary to what 
> Python users would expect.

No this is apparently plain wrong. Sorry.


-- 
Dag Sverre


More information about the Cython-dev mailing list