JuliaPy / JuliaPy/PythonCall.jl
Working with type instabilities, coming from PyJulia
- Ngôn ngữ chính
- Julia
- Star
- 1.1k
- Fork
- 86
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 3
Mô tả
@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
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Start by comparing the PythonCall/juliacall behavior in the example with the PyJulia behavior, focusing on how Python lists are converted when calling Julia functions through Main. Define the intended conversion and type-stability behavior, including the shown list-of-integers case, then check the related discussion in #439 for context before identifying tests or entry points.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- julia, python
- Lĩnh vực
- backend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100