[Numpy-discussion] Getting C-function pointers from Python to C
Dag Sverre Seljebotn
d.s.seljebotn@astro.uio...
Thu Apr 19 10:28:36 CDT 2012
On 04/19/2012 04:17 PM, Travis Oliphant wrote:
> Thanks for the status update. A couple of weeks is a fine timeline to wait.
>
> Are you envisioning that the ufuncs in NumPy would have the nativecall attribute?
I'm envisioning that they would be able to support CEP 1000, yes, but I
don't think they would necesarrily use the ufunc machinery or existing
implementation -- just a namespace mechanism, a way of getting the
"np.sin" to map to the libc (or npymath?) "sin" function.
Currently when translating
In Numba, if somebody writes:
from numpy import sin
@numba
def f(x):
return sin(x * x)
Then, at numbafication-time, you can presumably lift the "sin" object
out of the module scope, look at it, and through CEP 1000 figure out
that there's a "d->d" function pointer inside the sin object, and use
that a) for type inference, b) embed a jump to the function in the
generated code.
(If somebody rebinds "sin" after the numba decorator has run, they get
to keep the pieces)
I don't know how you planned on doing this now, perhaps special casing a
few NumPy functions? The nice thing is that through CEP 1000, numba can
transparently support whatever special function I write in Cython, and
dispatch to it *fast*.
Dag
More information about the NumPy-Discussion
mailing list