Friday, 27 September 2013

Extracting raw data from bytes object

Extracting raw data from bytes object

Using Boost Python, is there a better way to get the raw data out of a
Python 3 bytes object than this fairly nasty way?
py::object raw = <a bytes object>
int n = py::len(raw);
char *r = new char[n];
for(int i=0; i<n; ++i)
r[i] = py::extract<int>(raw[i]);
(Boost 1.48 with Python 3.2)

No comments:

Post a Comment