summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2010-02-21 02:45:30 +0000
committerPauli Virtanen <pav@iki.fi>2010-02-21 02:45:30 +0000
commitca540012019d6ff579819c5a789124bd541dc2e3 (patch)
tree88ae4fa24874bfa1742df6c5bc70a1c5eae69b35
parent69f7f4c7e3ca4af2ae79921895efa1c2a6b11c41 (diff)
downloadnumpy-ca540012019d6ff579819c5a789124bd541dc2e3.tar.gz
3K: ENH: ensure integer scalar types are hashable -- we don't automatically inherit the hash implementation from Python ints on 3K
-rw-r--r--numpy/core/src/multiarray/scalartypes.c.src20
1 files changed, 12 insertions, 8 deletions
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src
index e98805c1c..efdaa25ef 100644
--- a/numpy/core/src/multiarray/scalartypes.c.src
+++ b/numpy/core/src/multiarray/scalartypes.c.src
@@ -2438,7 +2438,7 @@ static long
}
/**end repeat**/
-#if SIZEOF_INT != SIZEOF_LONG
+#if (SIZEOF_INT != SIZEOF_LONG) || defined(NPY_PY3K)
static long
int_arrtype_hash(PyObject *obj)
{
@@ -2480,14 +2480,12 @@ static long
}
return y;
}
-#endif
-/**end repeat**/
+#else
-#if SIZEOF_LONG==SIZEOF_LONGLONG
static long
-ulonglong_arrtype_hash(PyObject *obj)
+@char@longlong_arrtype_hash(PyObject *obj)
{
- long x = (long)(((PyULongLongScalarObject *)obj)->obval);
+ long x = (long)(((Py@Char@LongLongScalarObject *)obj)->obval);
if (x == -1) {
x = -2;
}
@@ -2495,6 +2493,7 @@ ulonglong_arrtype_hash(PyObject *obj)
}
#endif
+/**end repeat**/
/**begin repeat
@@ -3286,12 +3285,17 @@ initialize_numeric_types(void)
Py@NAME@ArrType_Type.tp_hash = @name@_arrtype_hash;
/**end repeat**/
-#if SIZEOF_INT != SIZEOF_LONG
+#if (SIZEOF_INT != SIZEOF_LONG) || defined(NPY_PY3K)
/* We won't be inheriting from Python Int type. */
PyIntArrType_Type.tp_hash = int_arrtype_hash;
#endif
-#if SIZEOF_LONG != SIZEOF_LONGLONG
+#if defined(NPY_PY3K)
+ /* We won't be inheriting from Python Int type. */
+ PyLongArrType_Type.tp_hash = int_arrtype_hash;
+#endif
+
+#if (SIZEOF_LONG != SIZEOF_LONGLONG) || defined(NPY_PY3K)
/* We won't be inheriting from Python Int type. */
PyLongLongArrType_Type.tp_hash = longlong_arrtype_hash;
#endif