An array type and memory view types for Cython

After much discussion, it became clear (to me) that there is a need for different types of array containers and views in Cython. I therefore propose to add a memory managed array type and typed memory views.

What do we need?

What's there already?

The proposal

The idea is to augment Cython with three new types, namely

Why not different containers?

While there is the need for a memory managed sequence type in general, different behaviour can be implemented on top of that by re-implementing certain aspects as a view on any container type. This includes types that support only the buffer protocol, and it also includes other views. So it is a lot better to use a layered approach here than to make each of the above types separate container types that cannot interact without copying data.

The new types

The dynamic array type

The typed memory view

The SIMD view type

Syntax

There has been much discussion about a suitable syntax. The major proposal here was to add only a new syntax for the SIMD type (example: "int[:,:]" for a 2D type) and to leave the other types out. The alternative proposed here is not to add a new kind of bracket syntax, and instead use the type parametrisation feature described in CEP 506. This will support all three types in exactly the same way, both in Cython and in pure Python syntax.

Interaction of the three types

The array type is a container, but the memory view type and the SIMD type are views, so the question is how these types behave on slicing and on operations that require copies.

enhancements/arraysandviews (last edited 2009-06-20 07:25:47 by StefanBehnel)