Hello everyone. I want to call the function in the Dynamic Shared lib, do you know what code in python can do this? Thank you very much!
The following snippet of code might give you some directions.
from numba import njit from numba.core import types, typing from llvmlite import bindings bindings.load_library_permanently('/path/to/shared_library.so') # calls hypot from libm # https://cplusplus.com/reference/cmath/hypot/ c_func_name = 'hypot' return_type = types.float64 argty = types.float64 c_sig = typing.signature(return_type, argty) c_hypot = types.ExternalFunction(c_func_name, c_sig) @njit def example(arg): return c_hypot(arg) print(example(3.3))
@guilherme Thank you, this is very useful! Would it be worth adding such a snippet to the official documentation?
Sure, I can send a PR including this.