Dag Sverre Seljebotn wrote: > Stefan Behnel wrote: >> we have three types: >> >> 1) a dynamic array type >> - allocates memory on creation >> - reallocates on (explicit) resizing, e.g. a .resize() method >> - supports PEP 3118 (and disables shrinking with live buffers) >> - returns a typed value on indexing >> - returns a typed array copy on slicing >> - behaves like a tuple otherwise >> >> 2) a typed memory view >> - created on top of a buffer (or array) >> - never allocates memory (for data, that is) >> - creates a new view object on slicing >> - behaves like an array otherwise > > This last point is dangerous as we seem to disagree about what an array > is.
It's what I described under 1). >> 3) a SIMD memory view >> - created on top of a buffer, array or memory view >> - supports parallel per-item arithmetic >> - behaves like a memory view otherwise > > Good summary. Starting from this: I want int[:,:] to be the combination > of 2) and 3) You mean "3) and not 2)", right? Could you explain why you need a syntax for this if it's only a view? I understand that the compiler needs to see the type, but I don't understand why you need a syntax other than a known type name that wraps 'something'. > An issue which is not covered here is that when doing > > cdef your-type-3) a, b, c > # assign b and c > a = b + c > > then new memory must be created as the target of "b + c", and then 3) > will be hard-coded to allocate something (which could likely be 1), but > there will be no references to it anywhere it except through 3), so no > resize can happen). Well, the plus operation of the SIMD type would create a new array (or, if it is smart enough, something close to the input types), do the calculation, wrap the result in a new SIMD memory view and return that, so that it gets assigned to 'a'. Did you mean the question of determining the target type, or why do you consider this tricky? Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
