On May 21, 2009, at 11:16 AM, Dag Sverre Seljebotn wrote: > A decision is needed here within a few weeks; it would be great if any > core developers who don't care could respond to vote 0.
Sorry, I flagged this as something I wanted to reply to after reading your wiki pages on the topic, and then it scrolled off the top of my cython folder... > However this creates some syntax issues: > > A) Currently > > cdef object[int] arr = ... > > can be used for PEP 3118 access on a generic object. While not a > technical problem (object will never become a template), it looks a > bit > odd when introducing with a template feature. > > B) How would a templated buffer type look like? MyType[int][float]? > > Proposal: > > The object[int] syntax is removed (are anyone using it?). It's a good idea to have a non-conflicting syntax like int[:], but I don't think we should be treating ndarray[int] and object[int] any differently, or removing backwards compatibility. > This is basically done by making any cdef class with the > __cythonbufferdefaults__ magic attribute become a "buffer template". > Such cdef classes cannot be templates. Any other class cannot be > used as > a buffer-supporting object. Are you suggesting we require __cythonbufferdefaults__ for all buffer classes? __cythonbufferdefaults__ doesn't make sense for, e.g., ndarrays. > This removes functionality (much numeric code could care less about > whether the underlying object is an ndarray). As a substitute, the > main > idea in http://wiki.cython.org/enhancements/buffersyntax is accepted, > which is to use > > cdef int[:] arr = ... > > for generic access, without any object access (this means that for now > only indexing and getting the shape is allowed at all.) I like the int[:] syntax, but I'm -1 on the raw buffer no-object- access idea. Having to write cdef object foo = ... cdef int[:] foo_buf = foo 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 - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
