Ability to give back a C function pointer of a specific type #141

mwiebe opened this Issue Feb 28, 2013 · 2 comments


None yet

2 participants

mwiebe commented Feb 28, 2013

Would like to be able to get a Numba-JITted function of a specific prototype.

An example result would be the following Python code

before_computed_column = struct([('x', float32), ('y', float32)])
with_computed_column = struct([('mean', float32), ('x', float32), ('y', float32)])
@jit(void(with_computed_column.pointer(), before_computed_column.pointer(), void.pointer()), ctypes=True)
def cc_kernel(dst, src, null):
    dst.mean = (src.x + src.y) / 2.0
    dst.x = src.x
    dst.y = src.y

translated into something equivalent to the following C code

struct with_computed_column {
    float mean, x, y;

struct before_computed_column {
    float x, y;

void cc_kernel(with_computed_column *dst, const before_computed_column *src, void *)
    dst->mean = (src->x + src->y) / 2.f;
    dst->x = src->x;
    dst->y = src->y;

I'm bumping this to 0.8, since the function wrappers and the code creating them are different in the autoclass branch.


The struct pointer support isn't quite there yet, but you should be able to get ctypes functions from jit functions now using numba.addressof().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment