Exposing a C string without copying to python 3.x code Exposing a C string without copying to python 3.x code python-3.x python-3.x

Exposing a C string without copying to python 3.x code


According to this thread the second argument to PyBuffer_FillInfo is optional. Could you pass NULL in its place? If not you could just create a PyBuffer instance yourself and fill the appropriate fields.


It sounds to me as though you should create your own custom type and implement the methods in tp_as_sequence (and possibly tp_as_buffer) as appropriate.