Skip to content

Instantly share code, notes, and snippets.

@astagi
Last active September 14, 2018 21:59
Show Gist options
  • Save astagi/217d3ee05923c7e427bd5669668c6879 to your computer and use it in GitHub Desktop.
Save astagi/217d3ee05923c7e427bd5669668c6879 to your computer and use it in GitHub Desktop.
package main
// #cgo pkg-config: python3
// #include <Python.h>
// int PyArg_ParseTuple_LL(PyObject *, long long *, long long *);
import "C"
import (
"fmt"
)
//export sum
func sum(self, args *C.PyObject) *C.PyObject {
var a, b C.longlong
if C.PyArg_ParseTuple_LL(args, &a, &b) == 0 {
return nil
}
return C.PyLong_FromLongLong(a + b)
}
func main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment