string isn't an option, because I need to support arbitrary data, which is often not unicode-valid. I also tried using a function signature that returns a char[]. Either way, the code raises UnicodeDecodeError when invoked in python.
For now, my workaround is to return a ubyte[] and then call bytes(returned_val). But that adds an unnecessary copy (and a 20% slowdown) that I'd rather avoid.
The
bytes
type isn't listed here: https://pyd.readthedocs.io/en/latest/conversion.html#d-to-pythonWhat D type should I use to return a
bytes
value?string
isn't an option, because I need to support arbitrary data, which is often not unicode-valid. I also tried using a function signature that returns achar[]
. Either way, the code raisesUnicodeDecodeError
when invoked in python.For now, my workaround is to return a
ubyte[]
and then callbytes(returned_val)
. But that adds an unnecessary copy (and a 20% slowdown) that I'd rather avoid.