caketop / python-starlark-go

🐍 Python bindings for starlark-go 🐍
https://python-starlark-go.readthedocs.io/
Apache License 2.0
20 stars 7 forks source link

Use cgo.Handle for state #169

Closed jordemort closed 1 year ago

jordemort commented 1 year ago

Instead of keeping interpreter state in a homemade global map, use a library that is specifically designed for passing Go pointers back and forth to C.

colindean commented 1 year ago

Neat. Does this afford any performance benefit? Or is it one of those things that's just less stuff for this code to handle once delegated to cgo?

jordemort commented 1 year ago

I'm not sure if it would have any performance benefit, but after finding that library I realized I had essentially recreated it by hand because I didn't know about it. It feels a lot cleaner to use it to me, because there are no longer any global variables in on the Go side; at least, there aren't any more in this code that you can see :)