On Mon, Jun 8, 2009 at 4:39 AM, Dag Sverre Seljebotn<[email protected]> wrote: > 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. > > *bump* > > Unless I hear something, I'm going to assume that people trust my > opinion here and start implementing the solution below (it's kind of a > blocker for Kurt's GSoC). Speak now or forever hold your peace...
The new syntax is fine with me, but you already knew that, and I'd be presuming a lot to say I'm a core developer ;-) I've some clarifying questions below since my understanding of templates is fairly basic. >> >> The decision was made to use [] for templates. To reiterate the main >> arguments: >> >> - It leaves the way open for exporting pre-instantiated templates to >> Python in a /very/ natural fashion. >> >> - Templates are a bit like a collection of types anyway. >> >> >> 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?). 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. 'removed': so no one can use cdef object[int] foo = ... anymore? Or it has different semantics (must be a 'buffer template' cdef class)? I presume all the current syntax for buffer indexing will still be around for backwards compatibility. >> >> 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 What functionality is removed exactly? The fast indexing with cdef ints, and all buffer access is now through the object's __getitem__ and __setitem__ only? >> >> 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've been wondering a lot about whether this is the right way, and it >> still seems so, even if it means that there will be (and likely continue >> to be) two different ways of accessing a buffer; one through an explicit >> "buffer type" and one through an "automatic template". Just to be clear: the "buffer type" is the cdef int[:], and the 'automatic template' is the cdef MyObj[int]. Both will be indexable, with the first using default 'fast' indexing on the buffer itself, and the second indexing through the MyObj.__getitem__. Right? Kurt _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
