[C++-sig] passing buffer of bytes from Python to C++

Dan Halbert halbert at bbn.com
Wed Mar 10 00:43:38 CET 2004

One of the C++ methods I've wrapped with BPL has a signature something like

    process_data(unsigned char const* buffer, unsigned long buffer_length)

In other words, it's just taking a buffer of bytes (it's 8-bit audio
data), which I'll be reading from a file or a network connection in

I can make the Python data object whatever I want (string, list,
tuple), but I see that BPL doesn't convert any of these to a char
pointer automatically. Is there a way to generate a simple char*
buffer with Python and BPL?

Later I'll also want to do the same thing for buffers of 16-bit
values, so is that also possible?

Thanks, and continuing thanks for putting up with all my questions,

More information about the Cplusplus-sig mailing list