How to pass string argument to numba njit python function from inside another whilst specifying signature type?

I posted this on stackoverflow but I thought I’d also post the question here. Any help would be hugely appreciated!

Hi @whatsmypurpose

I think unfortunately that this hits a bug, I’ve reported it here: Missing conversion from StringLiteral to unicode_type · Issue #6907 · numba/numba · GitHub

Ah okay, thanks a lot for your reply @stuartarchibald

Do you need the bar function to be AOT exported? If not, I think you might be able to just @njit decorate it and not specify a signature and it’ll compile. e.g.

import numba as nb
from numba import njit, types
from numba.pycc import CC

cc = CC('foo_extensionlib')

@njit
def bar(string):
    pass

@cc.export('foo1', nb.void(types.unicode_type))
@njit(nb.void(types.unicode_type))
def foo1(string):
    bar(string)

@cc.export('foo2', nb.void(types.unicode_type))
@njit(nb.void(types.unicode_type))
def foo2(string):
    bar("Testing")

That’s interesting, thanks for the suggestion I think that’d work nicely!

No problem, glad that’ll work for you!