[Numpy-discussion] Question about Optimization (Inline, and Pyrex)

David M. Cooke cookedm@physics.mcmaster...
Wed Apr 18 01:33:55 CDT 2007

Hash: SHA1

Anne Archibald wrote:
> It would be perfectly possible, in principle, to implement an
> ATLAS-like library that handled a variety (perhaps all) of numpy's
> basic operations in platform-optimized fashion. But implementing ATLAS
> is not a simple process! And it's not clear how much gain would be
> available - it would almost certainly be noticeably faster only for
> very large numpy objects (where the python overhead is unimportant),
> and those objects can be very inefficient because of excessive
> copying. And the scope of improvement would be very limited; an
> expression like A*B+C*D would be much more efficient, probably, if the
> whole expression were evaluated at once for each element (due to
> memory locality and temporary allocation). But it is impossible for
> numpy, sitting inside python as it does, to do that.

numexpr (in the scipy sandbox) does something like this: it takes an
expression like A*B+C*D and constructs a small bytecode program that
does that calculation in chunks, minimising temporary variables and
number of passes through memory. As it is, the speed is faster than the
python expression, and comparable to that of weave. I've been thinking
of making a JIT for it, but I haven't had the time :)

- --
|David M. Cooke              http://arbutus.physics.mcmaster.ca/dmc/
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the Numpy-discussion mailing list