numpy.pxd: Old iteration method did not iterate dtype in order (fixes #371)
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 25 Sep 2009 07:45:24 +0000 (09:45 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 25 Sep 2009 07:45:24 +0000 (09:45 +0200)
Cython/Includes/numpy.pxd

index 3fb343d8dafa7d2f134e2e2023d3a39ca1ae8157..cb766f6348478499fef879986136b5b8dcd2b3c9 100644 (file)
@@ -124,7 +124,7 @@ cdef extern from "numpy/arrayobject.h":
         cdef int itemsize "elsize"
         cdef char byteorder
         cdef object fields
-        cdef object names
+        cdef tuple names
 
     ctypedef extern class numpy.flatiter [object PyArrayIterObject]:
         # Use through macros
@@ -696,10 +696,11 @@ cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset
     cdef tuple i
     cdef int endian_detector = 1
     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
+    cdef tuple fields
     
-    for i in descr.fields.itervalues():
-        child = i[0]
-        new_offset = i[1]
+    for childname in descr.names:
+        fields = descr.fields[childname]
+        child, new_offset = fields
 
         if (end - f) - (new_offset - offset[0]) < 15:
             raise RuntimeError("Format string allocated too short, see comment in numpy.pxd")