JuliaPy / JuliaPy/pyjulia

jl_get_global can not get julia function pointer from Python to Julia

Open
#386 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
893
Forks
101
PR merge metrics
No merged PRs in 30d

Description

Hello,

I try to use PyJulia API to get and call Julia function, but it can not get function pointer.
The python I use is 3.7.4, Julia is 1.4.2 and PyJulia is 0.5.3.

The test python code is
```
from julia.api import LibJulia
api = LibJulia.load()
api.init_julia()

ret = api.jl_eval_string(b"sqrt(2.0)"); # OK
print(api.jl_unbox_float64(ret)) # OK

base = api.jl_eval_string(b"Base")
sqrt = api.jl_symbol(b"sqrt")
func_sqrt = api.jl_get_global(base, sqrt)
print(func_sqrt) # always 0 here

ret = api.jl_call1(func_sqrt, api.jl_box_float64(2.0)) #fail to call the function. The error is
# Traceback (most recent call last):
# File "testPyJulia.py", line 13, in
# ret = api.jl_call1(func_sqrt, api.jl_box_float64(2.0))
# ctypes.ArgumentError: argument 1: : Don't know how to convert parameter 1

print(api.jl_unbox_float64(ret))
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.