numarray speed question

grv grv575 at hotmail.com
Thu Aug 5 01:14:16 EDT 2004


squirrel at WPI.EDU (Christopher T King) wrote in
<Pine.LNX.4.44.0408040845120.27254-100000 at ccc6.wpi.edu>: 

>On Wed, 4 Aug 2004, grv wrote:
>
>> So it is supposed to be very fast to have an array of say 5 million 
>> integers stored in a binary file and do
>> 
>> a = numarray.fromfile('filename', (2, 2, 2))
>> numarray.add(a, 9, a)
>> 
>> but how is that faster than reading the entire file into memory and
>> then having a for loop in C:
>>    (loop over range) {
>>       *p++ += 9      }
>> 
>> or is that essentially what's going on?
>
>That's essentially what's going on ;) The point of numarray isn't to be 
>hyper-fast, but to be as fast as the equivalent C (or Fortran, or 
>what-have-you) implementation.  In many cases, it's faster, because 
>numarray is designed with several speed hacks in mind, but it's nothing 
>you can't do (without a little work) in C.
>

Yes but see I'm interested in what speed hacks can actually be done to 
improve the above code.  I just don't see anything that can iterate and add 
over that memory region faster.



More information about the Python-list mailing list