[Numpy-discussion] Power optimization branch merged to Numpy trunk

David M. Cooke cookedm at physics.mcmaster.ca
Tue Mar 7 14:59:04 CST 2006

Since Tim and I are now fiddling around with numexpr, I've merged what
we've got with the power optimization to the Numpy trunk.

This includes:

* x**2 is _as_fast_ as x*x now
* optimization of x**n for x as an array and n as a Python scalar.
* x**2, x**(-1), x**0 are optimized to use the new square, reciprocal,
  and ones_like ufuncs
* complex integer powers should be faster

Also, PyArray_FromAny has been speeded up when converting Python
scalars. A side effect of this change is that the array protocol won't
be looked for on subclasses of Python scalars (int, long, float,
complex). I don't expect that to be a problem.

Some things we hadn't got around to:
- integer arrays to a power (currently, these use pow())
- more optimization of integer powers

enjoy the speed :-)

|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca

More information about the Numpy-discussion mailing list