From: Nader Al-Naji <iamnotna...@gmail.com>
Date: Fri, 27 Jul 2012 10:45:07 -0700 (PDT)
Local: Fri, Jul 27 2012 1:45 pm
Subject: Re: Best Practices for passing numpy data pointer to C ?
Great; thanks for the response! This is my first time posting here so it's After reading through all the responses, it appears as though Sturla's <dtype_t*> np.PyArray_DATA(arr) is the right way to go. It is superior to the &a[0] solution because it a = np.arange(10, dtype=int) # This works even if a hasn't been casted yet. # These cause errors if the array is not casted because a[0] and a.data cdef np.ndarray[long, ndim=1, mode="c"] x = a # After casting, everything works and is consistent. fprintf(stderr, "%lu %lu %lu\n", buf_ptr1, buf_ptr2, buf_ptr3) # Output for an example run-- all addresses are the same, which is what Not having to cast the array before extracting the buffer is useful if one So I think Sturla's solution is what we should use in the future. It has Anyone have any other reasons why Sturla's solution might not be a good Thanks, 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.
| ||||||||||||||