Re: [Python.NET] Efficient copy of .NET Array to ctypes or numpy array

2014-11-05 Thread Denis Akhiyarov
And more important question - is it possible to generalize the copying of python array object to managed C# array object without knowing the data type/size/length? On Wed, Nov 5, 2014 at 8:58 AM, Denis Akhiyarov wrote: > How to copy unmanaged array (python list/tuple or numpy array) into > manag

Re: [Python.NET] Efficient copy of .NET Array to ctypes or numpy array

2014-11-05 Thread Denis Akhiyarov
Finally decided to generate the managed object on Python side and return it to C# with no conversion necessary in C#. This way I can even wrap regular function with Python with @decorator to handle the conversion. I suppose the dynamic version of pythonnet may have auto conversion for Python 3, bu

Re: [Python.NET] Efficient copy of .NET Array to ctypes or numpy array

2014-11-05 Thread Denis Akhiyarov
How to copy unmanaged array (python list/tuple or numpy array) into managed C# array? I guess using Marshal.Copy, but can anyone point to example? Thanks, Denis On Thu, Oct 30, 2014 at 12:19 PM, Nikhil Garg wrote: > Thanks Brad and Jeff for the detailed info. For now, fromiter is serving > me w

Re: [Python.NET] Efficient copy of .NET Array to ctypes or numpy array

2014-11-05 Thread Jeffrey Bush
To copy from a list or tuple you need to use the Python buffer() function. You can use that on numpy arrays as well. In buffer form, the len() is the byte length so then you don't need to know the data type or size. However, some additional work would be required if you wanted to make sure the C# a