[Numpy-svn] r8197 - trunk/numpy/core/src/multiarray

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 20:45:30 CST 2010


Author: ptvirtan
Date: 2010-02-20 20:45:30 -0600 (Sat, 20 Feb 2010)
New Revision: 8197

Modified:
   trunk/numpy/core/src/multiarray/scalartypes.c.src
Log:
3K: ENH: ensure integer scalar types are hashable -- we don't automatically inherit the hash implementation from Python ints on 3K

Modified: trunk/numpy/core/src/multiarray/scalartypes.c.src
===================================================================
--- trunk/numpy/core/src/multiarray/scalartypes.c.src	2010-02-21 01:55:27 UTC (rev 8196)
+++ trunk/numpy/core/src/multiarray/scalartypes.c.src	2010-02-21 02:45:30 UTC (rev 8197)
@@ -2438,7 +2438,7 @@
 }
 /**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 @@
     }
     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 @@
 }
 
 #endif
+/**end repeat**/
 
 
 /**begin repeat
@@ -3286,13 +3285,18 @@
     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
 



More information about the Numpy-svn mailing list