|
Assignment from a list is slow in Numarray: msg#00059python.numeric.general
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 |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: A bug in creating array of long int.: 00059, Shin |
|---|---|
| Next by Date: | Re: Assignment from a list is slow in Numarray: 00059, Francesc Alted |
| Previous by Thread: | A bug in creating array of long int.i: 00059, Shin |
| Next by Thread: | Re: Assignment from a list is slow in Numarray: 00059, Francesc Alted |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |