JuliaPy / JuliaPy/PyCall.jl

argument types in class definitions

Open
#408 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Julia
Stars
1.5k
Forks
186
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.