In the SciPy sandbox there is a module that goes into this direction.
It was mentioned in the other optimization thread. numexpr:
http://projects.scipy.org/scipy/scipy/browser/trunk/Lib/sandbox/numexpr
This module needs to be combined with a derived array class where the
operators return unevaluated expressions (lazy evaluation). All
access methods and asarray must call the evaluation function. Like
you proposed.
The unevaluated expressions and a compiler for them are in the numexpr
module.
A very basic version of this would probably be not much work.
I would like to replace:
import numpy as N
by:
import lazynumpy as N
:-)
Regards Eike.