Re: numarray.array can be VERY slow



Edward C. Jones wrote:
Steven Bethard wrote:

 > As mentioned, this has nothing to do with numarray, and everything to
 > do with your inexplicable use of lists.  Why don't you just write this
 > as:
 >
 > arr = numarray.ones((8, 8, 256, 256), Float64)

The code I posted was simplified from a larger program which I have now revised. But I still ask: why did it take 4.3 seconds to run?

And I repeat, because you were using lists, not numarray. ;) If you want a numarray array, create it directly, don't create it from lists.


What's your real code look like? Are you sure you need two nested loops? If you're sure, can you do something like
import numarray as na
arr = na.zeros((8, 8, 256, 256))
for i in xrange(8):
for j in xrange(8):
arr[i,j] = na.ones((256, 256))
where you allocate the array first and then fill it?


STeVe
.



Relevant Pages

  • Re: numarray.array can be VERY slow
    ... Edward C. Jones wrote: ... > do with your inexplicable use of lists. ... Getting in there late cos I've been skiving ...
    (comp.lang.python)
  • Re: Washingtons Descent from Edmund Butler
    ... Gary Boyd Roberts' 2009 Edition of Ancestors of American Presidents lists one ... descent from Edward III, one from Edward I, and one from William the Lyon (not a ... Washington's Descent from Edmund Butler ...
    (soc.genealogy.medieval)
  • Re: Generating a list using keywords.
    ... create a script that will search for keywords assigned to specific citations ... > smith v. jones ... >> What I have is a long legal document that lists various legal cases (like ... for example) and each case citation relates to various ...
    (microsoft.public.word.docmanagement)
  • Re: The Bill Freehan Club
    ... It could be that Smith was better than Jones ... the best in baseball at his position. ... But if Hungadunga was also the best in the first half of the next ... which is why I presented the lists as a starting ...
    (rec.sport.baseball)
  • Re: Making a Sharepoint Field Unique
    ... Hi Edward, that's a good thing, but I want to make a field that I create ... > By default, most, if not all, lists and doc libraries have a field called ... > Microsoft MVP - Sharepoint Portal Server ... >> Is there any way to make a field in a SharePoint list unique? ...
    (microsoft.public.sharepoint.portalserver)