[Numpy-svn] r4260 - trunk/numpy/lib

numpy-svn@scip... numpy-svn@scip...
Fri Oct 19 14:31:18 CDT 2007


Author: oliphant
Date: 2007-10-19 14:31:16 -0500 (Fri, 19 Oct 2007)
New Revision: 4260

Modified:
   trunk/numpy/lib/function_base.py
Log:
Avoid extra copy if otype is object on output.

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2007-10-19 19:06:21 UTC (rev 4259)
+++ trunk/numpy/lib/function_base.py	2007-10-19 19:31:16 UTC (rev 4260)
@@ -950,12 +950,12 @@
             self.ufunc = frompyfunc(self.thefunc, nargs, self.nout)
 
         # Convert to object arrays first
-        newargs = [asanyarray(arg,dtype=object) for arg in args]
+        newargs = [array(arg,copy=False,subok=True,dtype=object) for arg in args]
         if self.nout == 1:
             _res = array(self.ufunc(*newargs),copy=False,
-                         subok=True).astype(self.otypes[0])
+                         subok=True,dtype=self.otypes[0])
         else:
-            _res = tuple([array(x,copy=False,subok=True).astype(c) \
+            _res = tuple([array(x,copy=False,subok=True,dtype=c) \
                           for x, c in zip(self.ufunc(*newargs), self.otypes)])
         return _res
 



More information about the Numpy-svn mailing list