Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert go struct to dict #22

Open
abemedia opened this issue Aug 3, 2022 · 6 comments
Open

Convert go struct to dict #22

abemedia opened this issue Aug 3, 2022 · 6 comments

Comments

@abemedia
Copy link

abemedia commented Aug 3, 2022

It would be great to have a helper function that converts a go struct or map to a Python dict.

As a matter of fact it would also be really useful to be able to convert other types, for example a function like ToPyObject which takes an interface and using reflection builds the relevant Python type.

A FromPyObject doing the reverse would be ideal too.

This would massively simplify interaction between Python and Go.

@aadog
Copy link

aadog commented Aug 12, 2022

@abemedia your dream is complete

Let's try it, python bindings cgo-less

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

@christian-korneck
Copy link
Collaborator

This is out of scope for the C-API bindidings. However, I'd be open to creating a pkg (within this module) with higher level abstractions on top of the base C-API bindings that help with common tasks, like importing a module or exchanging data. (The C-API bindings should continue to exist "untampered" however).

Would welcome PRs in that direction!

@christian-korneck
Copy link
Collaborator

christian-korneck commented Aug 15, 2022

@aadog Let's try it, python bindings cgo-less https://github.com/aadog/py3-go

thanks a lot, this looks like an amazing project, I will definitely try it. At a first look your project and this project don't seem to have exactly identical goals (for this project it's mainly C-API bindings that behave close to the original API - yours seems to have many more (which is quite exciting!)).

Any chance that you could clarify the license for your project? If it's compatible to this project, we might be able to steal from you. ;-)

@aadog
Copy link

aadog commented Aug 16, 2022

@christian-korneck He doesn't have any restrictions, you can use it as you like

Toys written when you are bored, I wish you a good time

@abemedia
Copy link
Author

I actually already did this in a fork. Happy to create a PR for it if it is acceptable.
What shall I call the sub-package?

@christian-korneck
Copy link
Collaborator

sure, a PR for further discussion would be welcome. I’d say let’s call it helpers for now, we can still discuss naming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants