JuliaPy / JuliaPy/PyCall.jl

argument types in class definitions

オープン
#408 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Julia
スター
1.5k
フォーク
186
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start at the @pydef macro implementation and trace how method arguments are currently converted, then inspect the IO/readinto path and its use of raw PyObject and PyBuffer. Done means typed arguments can control conversion, with PyAny retaining current behavior and PyObject suppressing auto-conversion as described.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
julia, python
領域
backend
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。