As the title suggests, I'd like to pass a byte array from c++ to python. I understand I would need to convert my byte array into a PyObject somehow but this is where I got stuck. Is there anyone who can help me out with this.
Thanks in advance,
PyBytes_FromString to the rescue assuming Python3+:
https://docs.python.org/3/c-api/bytes.html
Under Python2.x PyString_FromString:
*_FromString functions take const char* as arg. You say that you have a byte array. So I assume that's exactly what it is. It's a bit confusing but strings and byte arrays meant the same thing back in days. If you allow nulls in your sequence of bytes then *_FromStringAndSize might be a better choice.char*.