On 06/06/2010 06:51 PM, Embhi Karuche wrote:
I have a vector<unsigned char> whose contents I would like to copy
into a python::str.
Currently, I am doing:
string temp(myvector.begin(), myvector.end());
python::str data(temp);
How can I skip the intermediate copy?
You'll need to use the regular Python C API to avoid the temporary:
python::str data(
python::handle<>(
PyString_FromStringAndSize(&myvector.front(), myvector.size())
)
);
Note that this will not fail gracefully if myvector.empty().
Jim Bosch
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig