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

**URL:** https://numba.discourse.group/t/which-version-of-scipy-is-numba-scipy-currently-most-compatible-with/2272
**Category:** numba-scipy
**Created:** [November 15, 2023, 12:25am UTC](https://numba.discourse.group/t/which-version-of-scipy-is-numba-scipy-currently-most-compatible-with/2272 "2023-11-15T00:25:42Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![ofk123](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/ofk123/32/892_2.png) [@ofk123](https://numba.discourse.group/u/ofk123)
#### Post date: [November 18, 2023, 6:31pm UTC](https://numba.discourse.group/t/which-version-of-scipy-is-numba-scipy-currently-most-compatible-with/2272/5 "2023-11-18T18:31:43Z")

</div>

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

The short version is:

```auto
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](https://docs.scipy.org/doc/scipy/reference/special.cython_special.html#:~:text=(double)-,kv%3A,-double%20complex%20kv) 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:
> 
> ```auto
> 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`
> 
> ```auto
> 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](https://numba.readthedocs.io/en/stable/extending/high-level.html#importing-cython-functions) the following seems to work for me:
> 
> ```auto
> 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)`

---

_[View the full topic](https://numba.discourse.group/t/which-version-of-scipy-is-numba-scipy-currently-most-compatible-with/2272)._
