Jeff wrote:
> I can't seem to find any easy to convert a PythonBuffer (created in
> Python and passed to C#) to a byte[]. The best solution I've found so
> far is to call __getslice__ to get a string and convert that to a
> byte[]. Is there a better way to so this? If not, will __getslice__
> always return a string, or will it depend on how the buffer was
> created?

I think __getslice__ can return non-strings - it might return ByteArray
objects or array objects from the array module.  I would suggest calling 
ToString() and converting that to bytes.

We should probably expose some way to get at the bytes directly though.
We might even want to expose an IntPtr which could have the address of 
the bytes if they're available - given that's the basic reason for buffer
objects existence.

_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to