Register high-level specializations

0 views
Skip to first unread message

Juan Luis Cano

unread,
Feb 8, 2016, 3:14:13 PM2/8/16
to Numba Public Discussion - Public
Is it possible to register several high-level specializations for a numba function? Something like:

# funcs.py

@jit('f8(f8)')
def func(x):
    return x**2

@jit('i4(i4)')
def func(x):
    return x + 1

>>> func(10.)
100.
>>> func(10)
11

Right now Python semantics prevent me from doing this but I wonder if there's a way to make numba select a Python function according to the type of its arguments.

Regards,

Juan Luis Cano

Stanley Seibert

unread,
Feb 8, 2016, 3:37:34 PM2/8/16
to Numba Public Discussion - Public
Hi Juan,

A way to achieve this will be appearing in the Numba 0.24 release in a few weeks:


This lets you write a function that returns a different function to compile for each type signature.

If you are using conda, you can install our pre-release versions of Numba (built from git master after every PR merge) with:

conda install -c numba numba


--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.
To post to this group, send email to numba...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/a535a8d9-0e76-4c1a-9caa-e60e20f5d918%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Stanley Seibert

unread,
Feb 8, 2016, 3:38:47 PM2/8/16
to Numba Public Discussion - Public
I should note that this feature was inspired by a similar one in Julia, and requested by several Numba users, so thanks everyone for the suggestions!

Juan Luis Cano

unread,
Feb 9, 2016, 2:30:29 PM2/9/16
to Numba Public Discussion - Public
Thanks for the pointer! It looks interesting, though now that you mention it I prefer Julia syntax ;)
Reply all
Reply to author
Forward
0 new messages