PyObject_CallFunction and writable memory

Christopher Nebergall christopher.nebergall at
Wed Aug 26 06:32:28 CEST 2009

I'm working a patch to a hex editor (frhed) written in c++ so it can
load python scripts. Internally the c++ code has a unsigned char * of
possibly serveral hundred megs which I want to send into the python
code to modify.    What is the best way to send the unsigned char * as
writable memory into the python code, so I don't have to duplicate the
memory in order to return a modified copy?   I'm currently using
"PyObject_CallFunction(pFunc, "(s#)",p->lpbMemory, p->dwSize);" to
send an immutable string but I haven't seen what I need to set in the
format string which makes the data writable to python.    The solution
can be for either python 2.6 or 3.1.


More information about the Python-list mailing list