[Numpy-discussion] performance problem
oliphant.travis at ieee.org
Mon Jan 30 00:24:01 CST 2006
Gerard Vermeulen wrote:
>Hi Travis, thanks for your incredible quick fixes.
>numpy is about 5 times slower than numarray (on my numarray-friendly bi-pentium):
This is a coercion issue.
NumPy is exercising the most complicated section of the ufunc code
requiring buffered casting because you are asking it to combine a uint32
array with a signed scalar (so the only commensurable type is a signed
scalar of type int64. This is then coerced back into the unsigned array).
Look at the data-type of b = a << 8.
a<<=val where val = uint32(8) is in the header
You should see more commensurate times.
We can of course discuss the appropriateness of the coercion rules.
Basically scalars don't cause coercion unless they are of a different
kind but as of now signed and unsigned integers are considered to be of
different kinds. I think that there is a valid point to be made that
all scalar integers should be treated the same since Python only has one
way to enter an integer.
Right now, this is not what's done, but it could be changed rather easily.
More information about the Numpy-discussion