Allow more control over argument conversion
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
We currently extract all arguments using the FromPyObject trait and often run into conflicts whether this should be strict, i.e. basically only downcasting the Python objects to the Python equivalents of the target Rust types, or loose, i.e. using the most general available Python API to produce an instance the target Rust type even if these are conceptually unrelated. Concrete example as are PyBool/bool and whether this should use only downcasting or the full truth value testing procedure or PySequence/Vec which might check whether the Python type is actually or sequence or take any iterable and collect it into a Rust Vec.
One way to alleviate this issue is to allow the user to choose which strategy to pursue, for example by adding a #[pyo3(noconvert)] argument attribute to explicitly request a strict conversion.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the FromPyObject trait handles function arguments and how argument attributes are parsed. Compare strict downcasting with the broader conversion behavior described for PyBool/bool and PySequence/Vec. Done means users can explicitly request strict conversion, such as with a #[pyo3(noconvert)] argument attribute, without removing existing conversion behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100