On 12/21/2012 03:52 AM, simon zhang wrote:
How to converter std::string* in boost.python?I have to handle some data of c++ in python.The data may be big.So I return a pointer to python. But there are some errors.
If the data is big, and you really want to avoid a deep copy, the only way to use it is if you manually allocate the memory as a Python str object using the Python C API or return it as something else (like a NumPy array or buffer object, or a custom Boost.Python-wrapped class) that can hold C++-allocated memory. A Python str object always owns its own memory, and so does std::string, so you can't convert from one to the other without a deep copy.
Jim _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig