def METHOD_NAME(obj, writable=False):
    buf = Py_buffer()
    flags = PyBUF_WRITABLE if writable else PyBUF_SIMPLE
    PyObject_GetBuffer(py_object(obj), byref(buf), flags)
    try:
        buffer_type = c_char * buf.len
        return buffer_type.from_address(buf.buf)
    finally:
        PyBuffer_Release(byref(buf))