[pypy-dev] Interpretor for vectorized langugage

Paolo Giarrusso p.giarrusso at gmail.com
Fri Dec 17 00:12:10 CET 2010

On Thu, Dec 16, 2010 at 10:16, Armin Rigo <arigo at tunes.org> wrote:
> Hi,

>> have you seen numpy/scipy?

> Of course you are then going to hit the same problems that Ademan
> tries to solve for numpy/scipy, notably how to implement at least the
> basic linear algebra operations in such a way that the JIT can improve
> them.  There are various goals there, e.g. to turn Python (or Matlab)
> code like A+B+C, adding three matrices together, into one matrix
> operation instead of two (as it is now: (A+B)+C).  This is all a bit
> experimental so far.

[More about numpy/scipy]:
How about the ideas from C++ expression templates? Or even better,
some sort of lazy evaluation?

With C++ expression templates [1], (A+B) returns something like
PlusMatrix(A, B). When finally assigning to a variable, the copy
constructor converts this into a real matrix; in the following line:
D = (A+B) + C
PlusMatrix(PlusMatrix(A, B), C) is built, and D gets the result.

What they could further do, but they don't (see FAQ of uBlas [1]), is
to cache the result of evaluating a template when requested; that
could be cached (as in lazy evaluation - expressions like PlusMatrix
are not very different from thunks, in that case) or maybe JIT
compilation can recognize the constantness of this.

Best regards

[1] One library using them is Boost::uBlas, but the idea is much older:
Paolo Giarrusso - Ph.D. Student

More information about the Pypy-dev mailing list