pyd
pyd copied to clipboard
Returning Python3 bytes
The bytes type isn't listed here: https://pyd.readthedocs.io/en/latest/conversion.html#d-to-python
What 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 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.
there doesn't seem to be a good way to return bytes. can't have that.
https://github.com/ariovistus/pyd/pull/147