Here is sample code:
static PySequenceMethods class_seq; static PyTypeObject class_type_dsc = { ... }; ssize_t classmeth_len(PyObject* self) { if (not error) return sequence_size; else return -1; } int classmeth_contains(PyObject* self, PyObject* value) { if (not error) { if (value in self) return 1; else return 0; } else return -1; } PyMODINIT_FUNC PyInit_module() { class_seq.sq_length = classmeth_len; class_seq.sq_contains = classmeth_contains; class_type_dsc.tp_as_sequence = &class_seq; ... }