def py_str_to_go(py_str: str): str_bytes = py_str.encode() c_str = ffi.new("char[]", str_bytes) go_str = ffi.new("_GoString_ *", [c_str, len(str_bytes)]) return (go_str[0], c_str)
def py_bytes_to_go(py_bytes: bytes): c_bytes = ffi.new("char[]", len(py_bytes)) go_slice = ffi.new("GoSlice *", [c_bytes, len(py_bytes), len(py_bytes)]) return (go_slice[0], c_bytes)
def init_go_slice(): return ffi.new("GoSlice *")