this looks like what I need...I'm not concerned with leaking memory as it's a borrowed pointer which will be cleaned up in C code later. Thanks for the pointer.<br><br><div class="gmail_quote">On Sat, Nov 7, 2009 at 12:36 PM, Zachary Pincus <span dir="ltr"><<a href="mailto:zachary.pincus@yale.edu">zachary.pincus@yale.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Check out this thread:<br>
<a href="http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg01154.html" target="_blank">http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg01154.html</a><br>
<br>
In shot, it can be done, but it can be tricky to make sure you don't<br>
leak memory. A better option if possible is to pre-allocate the array<br>
with numpy and pass that buffer into the C code -- but that's not<br>
always possible...<br>
<br>
Zach<br>
<div><div></div><div class="h5"><br>
<br>
On Nov 6, 2009, at 10:18 PM, Chris Colbert wrote:<br>
<br>
> Are you bound to using ctypes as the only option?<br>
><br>
> This could be done quite easily in Cython...<br>
><br>
> On Fri, Nov 6, 2009 at 1:57 PM, Trevor Clarke <<a href="mailto:trevor@notcows.com">trevor@notcows.com</a>><br>
> wrote:<br>
>> I've found some info on ctypes and numpy but it mostly tells me how<br>
>> to pass<br>
>> numpy objects to C funcs. I've got a C func which returns a<br>
>> c_void_p to a<br>
>> buffer and I'd like to access the data using numpy without creating<br>
>> a copy<br>
>> of the data. Could someone point me in the right direction?<br>
>><br>
>> _______________________________________________<br>
>> NumPy-Discussion mailing list<br>
>> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
>> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
>><br>
>><br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br>