The Python Oracle

Error when compiling a Numba module with function using other functions inline

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Horror Game Menu Looping

--

Chapters
00:00 Error When Compiling A Numba Module With Function Using Other Functions Inline
01:19 Accepted Answer Score 5
01:50 Thank you

--

Full question
https://stackoverflow.com/questions/4932...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #numpy #numba

#avk47



ACCEPTED ANSWER

Score 5


I reached out to the numba devs and they kindly answered that adding the @njit decorator after @cc.export will make the function call type resolution work and resolve.

So for example:

@cc.export('product','float64(float64[:], float64[:])')
@njit
def product(a, b):
    prod = 0
    for i in range(a.size):
        prod += a[i] * b[i]
    return prod

Will make the product function available to others. The caveat being that it is entirely possible in some cases that the inlined function ends up with a different type signature to that of the one declared AOT.