Reputation: 13218
More specifically, what is the difference between:
def f(double[::1, :]):
pass
and
def f(np.ndarray[double, ndim=2, order='fortran']):
pass
?
Upvotes: 1
Views: 42
Reputation: 68722
The first is the newer "typed memoryview" style:
http://cython.readthedocs.io/en/latest/src/userguide/memoryviews.html
The second is the older buffer syntax:
http://cython.readthedocs.io/en/latest/src/tutorial/numpy.html#efficient-indexing
See the documentation on typed memoryviews for a comparison since it covers the differences pretty well.
The one thing that I don't is mentioned in the docs is that sometimes I found historically that the buffer syntax could be a little faster when passing arrays to functions that don't take much time to compute since acquiring the memoryview had a little bit more overhead, although it was more efficient when accessing data. I'm not sure if this is still the case, but it's probably worth benchmarking for your particular use case.
Upvotes: 2