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

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Oct 9 03:45:22 CDT 2006


Author: oliphant
Date: 2006-10-09 03:45:20 -0500 (Mon, 09 Oct 2006)
New Revision: 3294

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
Speed up concatenate and choose when sequence is an array.

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-10-09 07:47:06 UTC (rev 3293)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-10-09 08:45:20 UTC (rev 3294)
@@ -1751,6 +1751,21 @@
 		return (void*)PyErr_NoMemory();
 	}
 
+        if (PyArray_Check(op)) {
+                for (i=0; i<n; i++) {
+                        mps[i] = array_big_item((PyArrayObject *)op, i);
+                }
+                if (!PyArray_ISCARRAY(op)) {
+                        for (i=0; i<n; i++) {
+                                PyObject *obj;
+                                obj = PyArray_NewCopy(mps[i], NPY_CORDER);
+                                Py_DECREF(mps[i]);
+                                mps[i] = (PyArrayObject *)obj;
+                        }
+                }                        
+                return mps;
+        }
+
 	for(i=0; i<n; i++) {
 		otmp = PySequence_GetItem(op, i);
 		if (!PyArray_CheckAnyScalar(otmp)) {



More information about the Numpy-svn mailing list