Re: [C++-sig] Efficient string passing

2009-11-19 Thread Stefan Seefeld
On 11/19/2009 08:30 AM, Mohan Ganesalingam wrote: I believe this is impossible: Python treats strings as immutable, which means you can't manipulate them in-place, and there is no C API function There is apparently one exception to this, which I was utilising: char* PyString_AsString(PyObject

Re: [C++-sig] Efficient string passing

2009-11-19 Thread Mohan Ganesalingam
Thank you for the reply! As you spotted, I was making an embarrassingly idiotic typo (due to too much cut and pasting)... it should of course have been handle<> h(result); return object(h); Once that was fixed, everything worked fine. I believe this is impossible: Python trea

Re: [C++-sig] Efficient string passing

2009-11-19 Thread Stefan Seefeld
On 11/19/2009 07:30 AM, Mohan Ganesalingam wrote: Dear all, I recently sent an e-mail which (I think) didn't reach the list, about trying to return large strings from C++ into Python without copying them. I believe this is impossible: Python treats strings as immutable, which means you can't

[C++-sig] Efficient string passing

2009-11-19 Thread Mohan Ganesalingam
Dear all, I recently sent an e-mail which (I think) didn't reach the list, about trying to return large strings from C++ into Python without copying them. By looking at the C/Python API I've subsequently figured out roughly how to do this... something like Class World { object return