[Numpy-discussion] Cython/NumPy syntax

Stéfan van der Walt stefan at sun.ac.za
Wed Aug 6 04:51:50 EDT 2008


2008/8/6 Dag Sverre Seljebotn <dagss at student.matnat.uio.no>:
>>> cdef numpy.ndarray[numpy.int64, ndim=2]
>>
>> I'd definitely prefer a comma between the two, and an (optional) ndim
>> keyword argument if possible.
>
> I'm taking this as a vote in favor of this and against "2D" and <>?
>
> The keyword is already present in optional form (you can do already do
> "ndarray[ndim=3, dtype=numpy.int64]" if you want to). So I meant to ask
> whether making it mandatory is a good solution so that the 2 doesn't
> look like a length specifier.

I prefer having the `ndim` present -- immediately, the code becomes
more transparent to a foreign eye.

> (ndim=2 seems too long for me though, which is why I am pondering "2D".)

The length doesn't bother me much (I prefer typing the extra 4
characters to make the code more readable).  Personally, I'd prefer
not to use 2D -- it's surprising to see a string like that without
enclosing quotes (you'd never see it in Python, for example).

> It is looking bright and some experimental support will be present in
> the next Cython release. What might be missing first time around is
> support for complex numbers, records/structs and object dtypes.

That is great news; please keep us up to date.  Thanks for all your hard work!

Regards
Stéfan



More information about the NumPy-Discussion mailing list