JuliaPy / JuliaPy/PythonCall.jl

Working with type instabilities, coming from PyJulia

未关闭
#441 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Julia
星标
1.1k
派生
86
平均合并
1 天 22 小时
30 天内合并 PR
3

描述

@cjdoris Is there an automatic way to force type conversions when passing Python objects to methods? Or, in other words, is there a way to automatically convert Python arguments to their Julia counterparts?

For example I am running into this issue right now when I pass a list of integers:

```python
>>> from juliacall import Main as jl
>>> jl.seval("f(x) = (@show typeof(x); nothing)")
Julia: f (generic function with 1 method)
>>> jl.f([1, 2, 3])
typeof(x) = PyList{Any}
```

which causes some issues as now `f` is unaware of the element type of this vector.

However, in PyJulia, arguments seem to somehow get converted automatically:

```python
>>> from julia import Main as jl
>>> jl.eval("f(x) = (@show typeof(x); nothing)")

>>> jl.f([1, 2, 3])
typeof(x) = Vector{Int64}
```

Is there a way to get this same behavior in PythonCall?

---

Possibly related to #439

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。