#include typedef struct { PyObject_HEAD /* Type-specific fields go here. */ } SimpleObject; static PyTypeObject SimpleObjectType = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "simpletype.Simple", /* tp_name */ sizeof(SimpleObject), /* tp_basicsize */ 0, /* tp_itemsize */ 0, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ "Simple objects are simple.", /* tp_doc */ }; PyMODINIT_FUNC initsimpletype(void) { PyObject* m; SimpleObjectType.tp_new = PyType_GenericNew; if (PyType_Ready(&SimpleObjectType) < 0) return; m = Py_InitModule3("simpletype", NULL, "Example module that creates an extension type."); if (m == NULL) return; Py_INCREF(&SimpleObjectType); PyModule_AddObject(m, "Simple", (PyObject *)&SimpleObjectType); }