Skip to content

Instantly share code, notes, and snippets.

@astagi
Last active September 14, 2018 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astagi/84c5d487b64d104455c10e199a5c3c2e to your computer and use it in GitHub Desktop.
Save astagi/84c5d487b64d104455c10e199a5c3c2e to your computer and use it in GitHub Desktop.
#define Py_LIMITED_API
#include <Python.h>
#include "libnewmath.h"
PyObject *sum_wrapper(PyObject *obj, PyObject *args) {
const long a, b;
if (!PyArg_ParseTuple(args, "LL", &a, &b))
return NULL;
return PyLong_FromLong(sum(a, b));
}
static PyMethodDef NewMathMethods[] = {
{"sum", sum_wrapper, METH_VARARGS, "Add two numbers."},
{NULL, NULL, 0, NULL}
};
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment