[Numpy-discussion] Cython numerical syntax revisited

Francesc Alted faltet@pytables....
Thu Mar 5 02:39:29 CST 2009


A Thursday 05 March 2009, Dag Sverre Seljebotn escrigué:
> But yes, to implement that one would need to reimplement parts of
> NumPy to get it working. But because code would be generated
> specifically for the situation inline, I think it would be more like
> reimplementing Numexpr than reimplementing NumPy. I think one could
> simply invoke Numexpr as a first implementation (and make it an
> optional Cython plugin).

At first sight, having a kind of Numexpr kernel inside Cython would be 
great, but provided that you can already call Numexpr from both 
Python/Cython, I wonder which would be the advantage to do so.  As I 
see it, it would be better to have:

c = numexpr.evaluate("a + b")

in the middle of Cython code than just:

c = a + b

in the sense that the former would allow the programmer to see whether 
Numexpr is called explicitely or not.

One should not forget that Numexpr starts to be competitive only when 
expressions whose array operands+result sizes are around the CPU cache 
size or larger (unless transcental functions are used and local Numexpr 
has support for Intel VML, in which case this size can be substantially 
lower).  So, getting Numexpr (or the Cython implementation of it) 
automatically called for *every* expression should be not necessarily a 
Good Thing, IMO.

Cheers,

-- 
Francesc Alted


More information about the Numpy-discussion mailing list