Which version of scipy is numba-scipy currently most compatible with?

Interesting, thanks alot for pointing to the advice. I think I found a solution for now which I detail below.

The short version is:

from numba import njit
from numba.extending import get_cython_function_address
import ctypes
addr = get_cython_function_address('scipy.special.cython_special', '__pyx_fuse_1kv')
functype = ctypes.CFUNCTYPE(ctypes.c_double, ctypes.c_double, ctypes.c_double)
ckv = functype(addr)

@njit
def ckv_njit(v,z):
    return ckv(v,z)
Longer version in case others end up here:

On this website I see the function I want to run in no-python-mode ( scipy.special.kv(v,z) ). Its available as scipy.special.cython_special.kv.

I inspect cython_special to find the functionname for kv:

In [37]: [(x, cython_special.__pyx_capi__[x]) for x in cython_special.__pyx_capi__ if 'kv' in x]

Out [37]: [('__pyx_fuse_0kv',
  <capsule object "__pyx_t_double_complex (double, __pyx_t_double_complex, int __pyx_skip_dispatch)" at 0x7f16c2956730>),
 ('__pyx_fuse_1kv',
  <capsule object "double (double, double, int __pyx_skip_dispatch)" at 0x7f16c29558f0>),
 ('__pyx_fuse_0kve',
  <capsule object "__pyx_t_double_complex (double, __pyx_t_double_complex, int __pyx_skip_dispatch)" at 0x7f16c2954b40>),
 ('__pyx_fuse_1kve',
  <capsule object "double (double, double, int __pyx_skip_dispatch)" at 0x7f16c29561c0>)]

According to its types it seems the function I want is connected to the functionname __pyx_fuse_1kv

In [46]: cython_special.__pyx_capi__["__pyx_fuse_1kv"]
Out [46]: <capsule object "double (double, double, int __pyx_skip_dispatch)" at 0x7f16c29558f0>

From reading the documentation the following seems to work for me:

from numba import njit
from numba.extending import get_cython_function_address
import ctypes
addr = get_cython_function_address('scipy.special.cython_special', '__pyx_fuse_1kv')
functype = ctypes.CFUNCTYPE(ctypes.c_double, ctypes.c_double, ctypes.c_double)
ckv = functype(addr)

@njit
def ckv_njit(v,z):
    return ckv(v,z)

I only have one follow-up question:

  1. I would ideally like to be able to cache this function but I get the message below. Did you ever get around this somehow?
Warning

/tmp/ipykernel_365/431863534.py:1: NumbaWarning: Cannot cache compiled function "ckv_njit" as it uses dynamic globals (such as ctypes pointers and large global arrays)