Dag Sverre Seljebotn wrote: > Robert Bradshaw wrote: >> seems clunky to me--I really like that in the current system one >> doesn't have to have to separate variables to access a buffer as a >> fast array or a Python object--this fits in well with the whole >> Cython philosophy. (I do think we should print warnings for people >> who write A[i][j] (which is slower from Python too, and should be >> obvious if cython -a is run).) >> >> I would rather see int[:] be a type qualifier (like long, >> unsigned, ...) so one can write >> >> cdef int[:] object foo > > Hmm. I'm not against that -- would you then be ok with > > cdef int[:] foo > > not giving any object access at all? (The thing is I also want to use it > to access arrays stored in C pointers etc.; + safe passing around of > buffers in nogil mode!)
I really should reiterate a problem spot here: Efficient slicing. cdef object[int] a = np.arange(10) cdef object[int] b b = a[5:] # made efficient print b[0] # prints 5 print (<object>b)[0] # huh, prints 0? Either that, or print b.foo() # raises exception "NoneType has no attribute"? When loosing the underlying object reference from the syntax, this problems disappears, as one won't expect "b.foo()" to work in the first place. Then print (<object>b)[0] # prints 5 because b is coerced to a memoryview. -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
