[Numpy-discussion] Cython numerical syntax revisited

Matthew Brett matthew.brett at gmail.com
Fri Mar 6 13:27:08 EST 2009


Hi,

> The idea behind the current syntax was to keep things as close as
> possible to Python/NumPy, and only provide some "hints" to Cython for
> optimization. My problem with this now is that a) it's too easy to get
> non-optimized code without a warning by letting in untyped indices, b) I
> think the whole thing is a bit too "magic" and that it is too unclear
> what is going on to newcomers (though I'm guessing there).
>
> My proposal: Introduce an explicit "buffer syntax":
>
> arr = np.zeros(..)
> cdef int[:,:] buf = arr # 2D buffer

I like this proposal a lot; it seems a great deal clearer to me than
the earlier syntax; it helps me think of the new Cython thing that I
have in a different and more natural way.

Best,

Matthew



More information about the NumPy-Discussion mailing list