[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

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

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 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

[C++-sig] Boost.Python + OpenGL segmentation faults

2009-11-19 Thread Dimitri Tcaciuc
Hello everyone, I've recently posted a problem to SO (http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults), where I haven't had much luck with answer. My problem is that if I import OpenGL python libraries before importing my B.P bindings, I get strange segmentation

Re: [C++-sig] Boost.Python + OpenGL segmentation faults

2009-11-19 Thread troy d. straszheim
Dimitri Tcaciuc wrote: Hello everyone, I've recently posted a problem to SO (http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults), where I haven't had much luck with answer. My problem is that if I import OpenGL python libraries before importing my B.P bindings, I

Re: [C++-sig] Boost.Python + OpenGL segmentation faults

2009-11-19 Thread Ralf W. Grosse-Kunstleve
Just a remark: We are heavily using Boost.Python extensions together with OpenGL, and have so for years. It works for us without problems under Windows, Mac OS X, Linux. We are not using PyOpenGL, though, but have our own Boost.Python-based wrappers for the entire OpenGL library (http://cci.lbl.g