Make Python builtin types hashable by default
Default hash is the underlying C/C++ pointer. This matches up with testing for equivalence (Py_EQ in SwigPyObject_richcompare) which compares the pointers.
This commit is contained in:
parent
253a39fdff
commit
5b7c08c214
5 changed files with 53 additions and 16 deletions
|
|
@ -4057,6 +4057,7 @@ public:
|
|||
static String *tp_basicsize = NewStringf("sizeof(SwigPyObject)");
|
||||
static String *tp_dictoffset_default = NewString("offsetof(SwigPyObject, dict)");
|
||||
static String *tp_new = NewString("PyType_GenericNew");
|
||||
static String *tp_hash = NewString("SwigPyObject_hash");
|
||||
String *tp_as_number = NewStringf("&%s_type.as_number", templ);
|
||||
String *tp_as_sequence = NewStringf("&%s_type.as_sequence", templ);
|
||||
String *tp_as_mapping = NewStringf("&%s_type.as_mapping", templ);
|
||||
|
|
@ -4088,7 +4089,7 @@ public:
|
|||
printSlot(f, getSlot(n, "feature:python:tp_as_number", tp_as_number), "tp_as_number");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_as_sequence", tp_as_sequence), "tp_as_sequence");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_as_mapping", tp_as_mapping), "tp_as_mapping");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_hash"), "tp_hash", "hashfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_hash", tp_hash), "tp_hash", "hashfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_call"), "tp_call", "ternaryfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_str"), "tp_str", "reprfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_getattro"), "tp_getattro", "getattrofunc");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue