[Numpy-svn] r5095 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sat Apr 26 16:32:04 CDT 2008


Author: charris
Date: 2008-04-26 16:31:54 -0500 (Sat, 26 Apr 2008)
New Revision: 5095

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
revert to 5092


Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2008-04-26 18:57:06 UTC (rev 5094)
+++ trunk/numpy/core/src/multiarraymodule.c	2008-04-26 21:31:54 UTC (rev 5095)
@@ -2423,15 +2423,14 @@
     int elsize;
     intp astride;
     PyArray_SortFunc *sort;
-    BEGIN_THREADS_DEF;
+    BEGIN_THREADS_DEF
 
     it = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, &axis);
     swap = !PyArray_ISNOTSWAPPED(op);
-    if (it == NULL) {
-        return -1;
-    }
+    if (it == NULL) return -1;
 
-    NPY_BEGIN_THREADS_DESCR(op->descr);
+    NPY_BEGIN_THREADS_DESCR(op->descr)
+
     sort = op->descr->f->sort[which];
     size = it->size;
     N = op->dimensions[axis];
@@ -2447,16 +2446,12 @@
         while (size--) {
             _unaligned_strided_byte_copy(buffer, (intp) elsize, it->dataptr,
                                          astride, N, elsize);
-            if (swap) {
-                _strided_byte_swap(buffer, (intp) elsize, N, elsize);
-            }
+            if (swap) _strided_byte_swap(buffer, (intp) elsize, N, elsize);
             if (sort(buffer, N, op) < 0) {
-                PyDataMem_FREE(buffer);
-                goto fail;
+                PyDataMem_FREE(buffer); goto fail;
             }
-            if (swap) {
-                _strided_byte_swap(buffer, (intp) elsize, N, elsize);
-            }
+            if (swap) _strided_byte_swap(buffer, (intp) elsize, N, elsize);
+
             _unaligned_strided_byte_copy(it->dataptr, astride, buffer,
                                          (intp) elsize, N, elsize);
             PyArray_ITER_NEXT(it);
@@ -2465,20 +2460,20 @@
     }
     else {
         while (size--) {
-            if (sort(it->dataptr, N, op) < 0) {
-                goto fail;
-            }
+            if (sort(it->dataptr, N, op) < 0) goto fail;
             PyArray_ITER_NEXT(it);
         }
     }
 
-    NPY_END_THREADS_DESCR(op->descr);
-    Py_DECREF(it);
+    NPY_END_THREADS_DESCR(op->descr)
+
+        Py_DECREF(it);
     return 0;
 
  fail:
-    NPY_END_THREADS;
-    Py_DECREF(it);
+    END_THREADS
+
+        Py_DECREF(it);
     return 0;
 }
 
@@ -2494,7 +2489,7 @@
     int elsize, swap;
     intp astride, rstride, *iptr;
     PyArray_ArgSortFunc *argsort;
-    BEGIN_THREADS_DEF;
+    BEGIN_THREADS_DEF
 
     ret = PyArray_New(op->ob_type, op->nd,
                           op->dimensions, PyArray_INTP,
@@ -2507,7 +2502,7 @@
 
     swap = !PyArray_ISNOTSWAPPED(op);
 
-    NPY_BEGIN_THREADS_DESCR(op->descr);
+    NPY_BEGIN_THREADS_DESCR(op->descr)
 
     argsort = op->descr->f->argsort[which];
     size = it->size;
@@ -2553,17 +2548,17 @@
         }
     }
 
-    NPY_END_THREADS_DESCR(op->descr);
+    NPY_END_THREADS_DESCR(op->descr)
 
-    Py_DECREF(it);
+        Py_DECREF(it);
     Py_DECREF(rit);
     return ret;
 
  fail:
 
-    NPY_END_THREADS;
+    END_THREADS
 
-    Py_DECREF(ret);
+        Py_DECREF(ret);
     Py_XDECREF(it);
     Py_XDECREF(rit);
     return NULL;
@@ -2830,7 +2825,7 @@
     int object=0;
     PyArray_ArgSortFunc *argsort;
 
-    NPY_BEGIN_THREADS_DEF;
+    NPY_BEGIN_THREADS_DEF
 
         if (!PySequence_Check(sort_keys) || \
             ((n=PySequence_Size(sort_keys)) <= 0)) {
@@ -2902,9 +2897,7 @@
         PyArray_IterAllButAxis((PyObject *)ret, &axis);
     if (rit == NULL) goto fail;
 
-    if (!object) {
-        NPY_BEGIN_THREADS;
-    }
+    if (!object) {NPY_BEGIN_THREADS}
 
     size = rit->size;
     N = mps[0]->dimensions[axis];
@@ -2968,9 +2961,7 @@
         }
     }
 
-    if (!object) {
-        NPY_END_THREADS;
-    }
+    if (!object) {NPY_END_THREADS}
 
  finish:
     for (i=0; i<n; i++) {Py_XDECREF(mps[i]); Py_XDECREF(its[i]);}
@@ -2980,7 +2971,7 @@
     return (PyObject *)ret;
 
  fail:
-    NPY_END_THREADS;
+    NPY_END_THREADS
 
         Py_XDECREF(rit);
     Py_XDECREF(ret);
@@ -3112,8 +3103,9 @@
     PyArrayObject *ap2=NULL;
     PyArrayObject *ret=NULL;
     PyArray_Descr *dtype;
-    NPY_BEGIN_THREADS_DEF;
 
+    NPY_BEGIN_THREADS_DEF
+
     dtype = PyArray_DescrFromObject((PyObject *)op2, op1->descr);
 
     /* need ap1 as contiguous array and of right type */
@@ -3147,15 +3139,15 @@
     }
 
     if (side == NPY_SEARCHLEFT) {
-        NPY_BEGIN_THREADS_DESCR(ap2->descr);
-        local_search_left(ap1, ap2, ret);
-        NPY_END_THREADS_DESCR(ap2->descr);
-    }
+        NPY_BEGIN_THREADS_DESCR(ap2->descr)
+            local_search_left(ap1, ap2, ret);
+        NPY_END_THREADS_DESCR(ap2->descr)
+            }
     else if (side == NPY_SEARCHRIGHT) {
-        NPY_BEGIN_THREADS_DESCR(ap2->descr);
-        local_search_right(ap1, ap2, ret);
-        NPY_END_THREADS_DESCR(ap2->descr);
-    }
+        NPY_BEGIN_THREADS_DESCR(ap2->descr)
+            local_search_right(ap1, ap2, ret);
+        NPY_END_THREADS_DESCR(ap2->descr)
+            }
     Py_DECREF(ap1);
     Py_DECREF(ap2);
     return (PyObject *)ret;
@@ -3217,7 +3209,7 @@
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
 
-    NPY_BEGIN_THREADS_DEF;
+    NPY_BEGIN_THREADS_DEF
 
         typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
@@ -3282,7 +3274,7 @@
     it2 = (PyArrayIterObject *)\
         PyArray_IterAllButAxis((PyObject *)ap2, &axis);
 
-    NPY_BEGIN_THREADS_DESCR(ap2->descr);
+    NPY_BEGIN_THREADS_DESCR(ap2->descr)
         while(1) {
             while(it2->index < it2->size) {
                 dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
@@ -3293,7 +3285,7 @@
             if (it1->index >= it1->size) break;
             PyArray_ITER_RESET(it2);
         }
-    NPY_END_THREADS_DESCR(ap2->descr);
+    NPY_END_THREADS_DESCR(ap2->descr)
         Py_DECREF(it1);
     Py_DECREF(it2);
 
@@ -3328,8 +3320,9 @@
     intp dimensions[MAX_DIMS];
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
-    NPY_BEGIN_THREADS_DEF;
 
+    NPY_BEGIN_THREADS_DEF
+
         typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
 
@@ -3417,7 +3410,7 @@
     it2 = (PyArrayIterObject *)\
         PyArray_IterAllButAxis((PyObject *)ap2, &matchDim);
 
-    NPY_BEGIN_THREADS_DESCR(ap2->descr);
+    NPY_BEGIN_THREADS_DESCR(ap2->descr)
         while(1) {
             while(it2->index < it2->size) {
                 dot(it1->dataptr, is1, it2->dataptr, is2, op, l, ret);
@@ -3428,7 +3421,7 @@
             if (it1->index >= it1->size) break;
             PyArray_ITER_RESET(it2);
         }
-    NPY_END_THREADS_DESCR(ap2->descr);
+    NPY_END_THREADS_DESCR(ap2->descr)
         Py_DECREF(it1);
     Py_DECREF(it2);
     if (PyErr_Occurred()) goto fail;  /* only for OBJECT arrays */
@@ -3489,7 +3482,7 @@
         return NULL;
     }
     /* do 2-d loop */
-    NPY_BEGIN_ALLOW_THREADS;
+    NPY_BEGIN_ALLOW_THREADS
         optr = PyArray_DATA(ret);
     str2 = elsize*dims[0];
     for (i=0; i<dims[0]; i++) {
@@ -3501,7 +3494,7 @@
             iptr += str2;
         }
     }
-    NPY_END_ALLOW_THREADS;
+    NPY_END_ALLOW_THREADS
         Py_DECREF(arr);
     return ret;
 }
@@ -3521,7 +3514,7 @@
     PyArray_DotFunc *dot;
     PyArray_Descr *typec;
 
-    NPY_BEGIN_THREADS_DEF;
+    NPY_BEGIN_THREADS_DEF
 
         typenum = PyArray_ObjectType(op1, 0);
     typenum = PyArray_ObjectType(op2, typenum);
@@ -3577,7 +3570,7 @@
         goto fail;
     }
 
-    NPY_BEGIN_THREADS_DESCR(ret->descr);
+    NPY_BEGIN_THREADS_DESCR(ret->descr)
 
         is1 = ap1->strides[0]; is2 = ap2->strides[0];
     op = ret->data; os = ret->descr->elsize;
@@ -3601,7 +3594,7 @@
         ip1 += is1;
         op += os;
     }
-    NPY_END_THREADS_DESCR(ret->descr);
+    NPY_END_THREADS_DESCR(ret->descr)
 
         if (PyErr_Occurred()) goto fail;
     Py_DECREF(ap1);
@@ -3729,7 +3722,7 @@
     int elsize;
     int copyret=0;
 
-    NPY_BEGIN_THREADS_DEF;
+    NPY_BEGIN_THREADS_DEF
 
         if ((ap=(PyAO *)_check_axis(op, &axis, 0))==NULL) return NULL;
 
@@ -3798,14 +3791,14 @@
         if (rp != out) copyret = 1;
     }
 
-    NPY_BEGIN_THREADS_DESCR(ap->descr);
+    NPY_BEGIN_THREADS_DESCR(ap->descr)
     n = PyArray_SIZE(ap)/m;
     rptr = (intp *)rp->data;
     for (ip = ap->data, i=0; i<n; i++, ip+=elsize*m) {
         arg_func(ip, m, rptr, ap);
         rptr += 1;
     }
-    NPY_END_THREADS_DESCR(ap->descr);
+    NPY_END_THREADS_DESCR(ap->descr)
 
     Py_DECREF(ap);
     if (copyret) {
@@ -7400,16 +7393,14 @@
     if (!PyArg_ParseTuple(args, "|i", &kind)) return NULL;
 
     if (kind) {
-        NPY_BEGIN_ALLOW_THREADS;
-        while (a>=0) {
-            if ((a % 1000 == 0) &&
-                 PyOS_InterruptOccurred()) {
-                break;
+        Py_BEGIN_ALLOW_THREADS
+            while (a>=0) {
+                if ((a % 1000 == 0) &&
+                    PyOS_InterruptOccurred()) break;
+                a+=1;
             }
-            a+=1;
-        }
-        NPY_END_ALLOW_THREADS;
-    }
+        Py_END_ALLOW_THREADS
+            }
     else {
 
         NPY_SIGINT_ON



More information about the Numpy-svn mailing list