[Numpy-discussion] Faster fill
oliphant at ee.byu.edu
Mon Feb 27 16:44:02 CST 2006
>I''ve just posted a patch at
>that results in a 6-14x speed-up of ndarray.fill for simple
>datatypes. That's a bigger change than what I am confortable
>submiting to svn without a review. Also since I am not familiar with
>record arrays, I am not sure whether or not this change would break
>anything in that area. Finally, the patch only adresses a
>single-segment case, "strided" arrays would still use old code.
This looks like a good proceedure. For those less familiar with the
code. Sasha added an additional "data-type-function" to the structure
of data-type-specific functions. Each builtin data-type has a pointer
to a list of functions. A while ago I moved these functions out from
the data-type object so that they could grow.
This is probably a good fundamental operation for speeding up.
I would probably also not define the misaligned case, but just use the
default code for that case as well. This is consistent with the idea
that misaligned data will have slower operations.
To make your code work for record arrays you need to handle the VOID
case. I would just not define it for the void case at this point.
Several other data-type functions need to be improved to handle record
arrays (look at setitem and getitem for guidance) better anyway.
You also need to add a check so that if the function pointer is NULL,
the optimized function is not called.
But, generally, this is the right use of the data-type-functions. Good
More information about the Numpy-discussion