diff options
| author | William S Fulton <wsf@fultondesigns.co.uk> | 2016-08-23 18:15:35 +0100 |
|---|---|---|
| committer | William S Fulton <wsf@fultondesigns.co.uk> | 2016-08-23 19:06:36 +0100 |
| commit | 5b7c08c21449c407019f4484c91819a441e8bd9c (patch) | |
| tree | 8d0da2e462920a194e09106b2b82656068e2a80e /Source/Modules/python.cxx | |
| parent | 253a39fdffc9b3c270ba815d6e60f416a4ee46a7 (diff) | |
| download | swig-builtin-hashable.tar.gz | |
Make Python builtin types hashable by defaultbuiltin-hashable
Default hash is the underlying C/C++ pointer.
This matches up with testing for equivalence (Py_EQ in SwigPyObject_richcompare)
which compares the pointers.
Diffstat (limited to 'Source/Modules/python.cxx')
| -rw-r--r-- | Source/Modules/python.cxx | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d31554071..40d3d9a8a 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -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"); |
