second-state / wasmedge-bindgen

Let WebAssembly's exported function support more data types for its parameters and return values.
Apache License 2.0
30 stars 8 forks source link

[Python SDK] Support for python SDK #1

Open SAtacker opened 2 years ago

SAtacker commented 2 years ago

Hello all, As per my understanding, the wasmedge-bindgen makes it necessary to have an import object with functions return_result, return_error and then manually allocate memory according to data type by calling allocate then run the function that was written by the user and finally deallocate the allocated memory by calling deallocate. If this is correct, then for the python SDK should I write a new module named wasmedge-bindgen in C++ doing what the host/go/bindgen.go does? Or do you have any other recommendations? Thanks!

Untitled Diagram drawio

CC @juntao

juntao commented 2 years ago

My understanding is that you want to do it in two steps:

1 Create a C or C++ library for wasmedge-bindgen under the host/c or host/cpp folder.

2 Create a Python package wrapper for the C/C++ library under the host/python folder.

Is that correct? My question is #2 -- why can't we just create a wasmedge-bindgen in pure Python (like we did for golang)? The extra dependency on the C library seems to be unnecessary? Thanks.

SAtacker commented 2 years ago

My understanding is that you want to do it in two steps:

1 Create a C or C++ library for wasmedge-bindgen under the host/c or host/cpp folder.

2 Create a Python package wrapper for the C/C++ library under the host/python folder.

Is that correct? My question is #2 -- why can't we just create a wasmedge-bindgen in pure Python (like we did for golang)? The extra dependency on the C library seems to be unnecessary? Thanks.

1 Yes, it was that. But your #2 suggestion makes sense. I'll write it in python SDK just like go bindgen is written in go SDK.

Thanks

juntao commented 2 years ago

Sounds good. Thanks. Look forward to your contribution!