How to define a new type (class) in Python using C API?
This part of the docs (and surrounding ones) should give you most of the info you need. The xxsubtype.c sources provide one example module that defines a new class (as a subclass of list
, to show precisely how to do that, too) and xxmodule.c shows (among many other things) also how to define a new type.