Skip to content

Instantly share code, notes, and snippets.

@sklam
Created June 4, 2019 19:17
Show Gist options
  • Save sklam/24b3c4ca2f839cc7bf2e48d72a488e1b to your computer and use it in GitHub Desktop.
Save sklam/24b3c4ca2f839cc7bf2e48d72a488e1b to your computer and use it in GitHub Desktop.
from numba import njit
@njit
def foo(functor, a, b):
return bar(functor, functor(a, b), b)
@njit
def bar(functor, a, b):
return functor(a, b)
# First functor
@njit
def add(x, y):
return x + y
r = foo(add, 1, 2)
print(r)
# Second functor
@njit
def mult(x, y):
return x * y
r = foo(mult, 1, 2)
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment