JuliaPy / PythonCall.jl

Python and Julia in harmony.
https://juliapy.github.io/PythonCall.jl/stable/
MIT License
722 stars 61 forks source link

[pythoncall] jl.Pair generates tuple instead of Julia pair #313

Open hongyehu opened 1 year ago

hongyehu commented 1 year ago

Affects: JuliaCall

Describe the bug In python, with from juliacall import Main as jl jl.Pair(1,2) it will generate a tuple instead of julia pair like 1=>2.

system info Please provide detailed information about your system:

cjdoris commented 1 year ago

This isn't a bug, it's a feature: whenever you call a Julia function from Python, the inputs and outputs are converted according to the documented rules.

The next major version is likely to change this however, so that the outputs are not converted and are always returned as a wrapped Julia value, so the above code does what you expect.

For now, you can do jl.Pair._jl_raw()(1, 2)._jl_any().

Or pair = jl.seval("pyjl(Pair(1, 2))"); pair(1, 2).

github-actions[bot] commented 10 months ago

This issue has been marked as stale because it has been open for 60 days with no activity. If the issue is still relevant then please leave a comment, or else it will be closed in 7 days.

github-actions[bot] commented 10 months ago

This issue has been closed because it has been stale for 7 days. You can re-open it if it is still relevant.