JuliaPy / JuliaPy/PyCall.jl

argument types in class definitions

Abierto
#408 1 comentario 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Julia
Estrellas
1.5k
Forks
186
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

It would be nice to be able to specify argument types for methods when defining a Python class via `@pydef`. That is
```jl
@pydef type Foo
bar(self, x::T) = baz(x)
end
```
would turn into `PyObject(baz(convert(T, x)))` given the raw `x::PyObject`. The default `T` would be `PyAny`, as now.

This is especially useful to *suppress* the auto-conversion, via `bar(self, x::PyObject)`. For example, in the `IO` conversion I noticed that we aren't implementing `readinto` correctly: to read in-place, we will have to get the raw `PyObject` and use `PyBuffer` to wrap an `Array{UInt8}` around it.

cc @cstjean

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.