argument types in class definitions
- Vorherrschende Sprache
- Julia
- Sterne
- 1.5k
- Forks
- 186
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- julia, python
- Bereich
- backend
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100