Message8685

Author zyasoft
Recipients zyasoft
Date 2014-06-18.23:44:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403135079.31.0.32472550334.issue2169@psf.upfronthosting.co.za>
In-reply-to
Content
>>> from java.nio import ByteBuffer
>>> x = memoryview("foobar")
>>> ByteBuffer.wrap(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: wrap(): 1st arg can't be coerced to byte[]

This is also true of buffer.

The underlying problem appears to be a lack of a __tojava__ method in PyMemoryView/Py2KBuffer that will return the desired byte[] object. For contiguous/complete arrays, this should not require a copy.

It would be interesting if we could somehow support a method like http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html#wrap(byte[],%20int,%20int), which is a very common pattern in Java, but this seems difficult :)
History
Date User Action Args
2014-06-18 23:44:39zyasoftsetrecipients: + zyasoft
2014-06-18 23:44:39zyasoftsetmessageid: <1403135079.31.0.32472550334.issue2169@psf.upfronthosting.co.za>
2014-06-18 23:44:39zyasoftlinkissue2169 messages
2014-06-18 23:44:38zyasoftcreate