RE: [Numpy-discussion] Assignment from a list is slow in Numarray
Yo may try the aging module TableIO (http://php.iupui.edu/~mmiller3/python/). Just replace "import Numeric" by "import numarray as Numeric". It may give up to two-fold speed improvement. Since you have C skills, you might update the small C source to interact directly with numarray. Nadav -----Original Message----- From: Timo Korvola [mailto:tkorvola@e.math.helsinki.fi] Sent: Sun 19-Sep-04 20:35 To: numpy-discussion@lists.sourceforge.net Cc: Subject: [Numpy-discussion] Assignment from a list is slow in Numarray Hello, I am new to the list, sorry if you've been through this before. I am trying to do some FEM computations using Petsc, to which I have written Python bindings using Swig. That involves passing arrays around, which I found delightfully simple with NA_{Input,Output,Io}Array. Numeric seems more difficult for output and bidirectional arrays. My code for reading a triangulation from a file went roughly like this: coord = zeros( (n_vertices, 2), Float) for v in n_vertices: coord[ v, :] = [float( s) for s in file.readline().split()] This was taking quite a bit of time with ~50000 vertices and ~100000 elements, for which three integers per element are read in a similar manner. I found it was faster to loop explicitly: coord = zeros( (n_vertices, 2), Float) for v in n_vertices: for j, c in enumerate( [float( s) for s in file.readline().split()]): coord[ v, j] = c Morally this uglier code with an explicit loop should not be faster but it is with Numarray. With Numeric assignment from a list has reasonable performance. How can it be improved for Numarray? -- Timo Korvola URL:http://www.iki.fi/tkorvola ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
participants (1)
-
Nadav Horesh