numarray speed question
Christopher T King
squirrel at WPI.EDU
Wed Aug 4 08:47:41 EDT 2004
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.
More information about the Python-list
mailing list