You could write a .NET function to do this with fixed pointers and "memcpy" from the .NET array to the numpy data (the raw data). This would be the absolute fastest way, but does involve a number of assumptions (for example that the data in the two arrays are laid out in the same way). If you want I could probably write something up real quick. <div>
<br></div><div>Jeff<br><br>On Wednesday, May 21, 2014, Brad Friedman <<a href="mailto:brad@fie.us">brad@fie.us</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
An aside that may be useful:<br>
<br>
.net will skip array bounds checking within simple for-loops, as an optimization. But only if the binaries have all their optimizations turned on. A binary built for debug has them turned off. There is a huge speed up for iterating over an array when these optimizations are used. So make sure you are not looking at a compiler optimization configuration problem.<br>

<br>
> On May 21, 2014, at 3:21 AM, Dave Cook <<a href="javascript:;" onclick="_e(event, 'cvml', 'daverz@gmail.com')">daverz@gmail.com</a>> wrote:<br>
><br>
> I need to copy a .NET Array (e.g. Double[] or Byte[]) to a numpy array, but it seems the only way to do so is element by element, which is very slow.  Since we are copying a lot of data in real time, it creates a real bottleneck.<br>

><br>
> Alternatively, efficient conversion of the .NET array to a Python style byte string would allow numpy.fromstring() to be used for creating the numpy array.<br>
><br>
> (I see a similar question went unanswered on the list in August 2011, but I was hoping someone may have figured it out by now.)<br>
><br>
> Thanks,<br>
> Dave Cook<br>
> _________________________________________________<br>
> Python.NET mailing list - <a href="javascript:;" onclick="_e(event, 'cvml', 'PythonDotNet@python.org')">PythonDotNet@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/pythondotnet" target="_blank">https://mail.python.org/mailman/listinfo/pythondotnet</a><br>
_________________________________________________<br>
Python.NET mailing list - <a href="javascript:;" onclick="_e(event, 'cvml', 'PythonDotNet@python.org')">PythonDotNet@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pythondotnet" target="_blank">https://mail.python.org/mailman/listinfo/pythondotnet</a><br>
</blockquote></div>