static void ShowDictObject(PyDictObject* dictObject) { PyDictEntry* entry = dictObject->ma_table; int count = dictObject->ma_mask+1; int i; //输出key printf(" key : "); for(i = 0; i < count; ++i) { PyObject* key = entry->me_key; PyObject* value = entry->me_value; if(key == NULL) { printf("NULL"); } else { if(PyString_Check(key)) { if(PyString_AsString(key)[0] == '<') { printf("dummy"); } else { (key->ob_type)->tp_print(key, stdout, 0); } } else{ (key->ob_type)->tp_print(key, stdout, 0); } } printf("\t"); ++entry; } //输出value printf("\nvalue : "); entry = dictObject->ma_table; for(i = 0; i < count; ++i) { PyObject* key = entry->me_key; PyObject* value = entry->me_value; if(value == NULL) { printf("NULL"); } else { (key->ob_type)->tp_print(value, stdout, 0); } printf("\t"); ++entry; } printf("\n"); } static void IsTestDictObject(PyDictObject* mp,PyObject *key,Py_ssize_t n_used) { PyDictEntry *p; long strHash; PyObject* str = PyString_FromString("test"); strHash = PyObject_Hash(str); p = mp->ma_lookup(mp, str, strHash); if(p->me_value != NULL && (key->ob_type)->tp_name[0] == 'i') { PyIntObject* intObject = (PyIntObject*)key; printf("insert %d\n", intObject->ob_ival); ShowDictObject(mp); printf("n_used=%d\tma_used=%d\t ma_fill=%d\t ma_mask=%d\n",n_used,mp->ma_used,mp->ma_fill,mp->ma_mask); } }