On Fri, Jul 27, 2012 at 10:45 AM, Nader Al-Naji <iamnotna...@gmail.com> wrote:what happens if a is not a numpy array? If you create it in your
> <dtype_t*> np.PyArray_DATA(arr)
> is the right way to go. It is superior to the &a solution because it
> a = np.arange(10, dtype=int)
> # This works even if a hasn't been casted yet.
Cython code, you can be confident that it is, but if it's passed in,
who knows? and if you have to check, why not cast it?
> Not having to cast the array before extracting the buffer is useful if oneyou can cast it to a ndarray with unspecified type -- I suspect arr
> knows the size of the elements one is dealing with, but not necessarily the
will work there, too.
> So I think Sturla's solution is what we should use in the future. It has thewell, as Sturla points out, Cython essentially creates the same code
> same semantics as .data, which I think a lot of people really like, and it
> won't be compromised if numpy changes.
under the hood if you index the zeroth element anyway. My it's just
aesthetics, but I like the more pyhtonic looking: &arr
> Anyone have any other reasons why Sturla's solution might not be a good
Christopher Barker, Ph.D.
Emergency Response Division
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.