JuliaPy / JuliaPy/PythonCall.jl

Working with type instabilities, coming from PyJulia

Aberta
#441 4 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Julia
Estrelas
1.1k
Forks
86
Merge médio
1d 22h
PRs com merge (30d)
3

Descrição

@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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
julia, python
Domínio
backend
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.