NISHIO Hirokazu[Translate]
numba bisect
python
from bisect import bisect import numpy as np import numba # @numba.njit # NG def main(xs, x): print(bisect(xs, x)) main(np.arange(10), 3) # => 4

OK
python
... from bisect import bisect import numpy as np import numba @numba.njit def bisect(a, x, lo=0, hi=None): ... @numba.njit def main(xs, x): print(bisect(xs, x)) ...


adding a signature would involve implementing it for Numba

NG
python
from numba.pycc import CC cc = CC('my_module') @cc.export("bisect", "i8(i8[:], i8)") def bisect(a, x): ... @cc.export("main", "i8(i8[:], i8)") def main(xs, x): ... cc.compile()



"Engineer's way of creating knowledge" the English version of my book is now available on [Engineer's way of creating knowledge]

(C)NISHIO Hirokazu / Converted from [Scrapbox] at [Edit]