1.int对象的定义: typedef struct { PyObject_HEAD //所有对象都包含的对象头信息。 long ob_ival; //long类型 } PyIntObject;
Pyint_Type: PyTypeObject PyInt_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "int", sizeof(PyIntObject), 0, (destructor)int_dealloc, /* tp_dealloc / (printfunc)int_print, / tp_print / 0, / tp_getattr / 0, / tp_setattr / (cmpfunc)int_compare, / tp_compare / (reprfunc)int_to_decimal_string, / tp_repr / &int_as_number, / tp_as_number / 0, / tp_as_sequence / 0, / tp_as_mapping / (hashfunc)int_hash, / tp_hash / 0, / tp_call / (reprfunc)int_to_decimal_string, / tp_str / PyObject_GenericGetAttr, / tp_getattro / 0, / tp_setattro / 0, / tp_as_buffer / Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_INT_SUBCLASS, / tp_flags / int_doc, / tp_doc / 0, / tp_traverse / 0, / tp_clear / 0, / tp_richcompare / 0, / tp_weaklistoffset / 0, / tp_iter / 0, / tp_iternext / int_methods, / tp_methods / 0, / tp_members / int_getset, / tp_getset / 0, / tp_base / 0, / tp_dict / 0, / tp_descr_get / 0, / tp_descr_set / 0, / tp_dictoffset / 0, / tp_init / 0, / tp_alloc / int_new, / tp_new / (freefunc)int_free, / tp_free */ };
初始化
int_compare: