baz_ext.c (406B)
1 #include <Python.h> 2 3 static PyObject *ping() { 4 return PyUnicode_FromString("pong"); 5 } 6 7 static PyMethodDef methods[] = { 8 {"ping", ping, METH_VARARGS, "Ping function"}, 9 {NULL, NULL, 0, NULL} 10 }; 11 12 static struct PyModuleDef module = { 13 PyModuleDef_HEAD_INIT, 14 "ping", 15 NULL, /* no docs */ 16 -1, 17 methods 18 }; 19 20 PyMODINIT_FUNC 21 PyInit_baz_ext(void) 22 { 23 return PyModule_Create(&module); 24 } 25