go-python / cpy3

Go bindings to the CPython-3 API
MIT License
307 stars 50 forks source link

buffer protocol #10

Open christian-korneck opened 2 years ago

christian-korneck commented 2 years ago

I wonder if it would make sense to add the Python3 C-API functions related to the Python buffer protocol. This might make it easier to share bytes between Go and Python? (i.e. io.Reader/io.Writer stuff).

https://docs.python.org/3/c-api/buffer.html

aadog commented 2 years ago

@christian-korneck your dream is complete

Let's try it, python bindings cgo-less

https://github.com/aadog/py3-go

christian-korneck commented 2 years ago

@aadog do you have a buffer protocol example?

aadog commented 2 years ago

What is he

aadog commented 2 years ago

go to python or python to go,They are done automatically

string->str intT ->intT

If it is not supported, please return * pyobject to convert manually, or modify pyconvert

https://github.com/aadog/py3-go/blob/master/PyConvert.go

aadog commented 2 years ago

All this should be simple, but I don't know what type of byte should be converted to Python