PyO3 / PyO3/pyo3

Implementation of conversion traits for 3rd party types

Open
#497 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

needs-design
Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

PyO3 kind of has the same problem as serde: if you wanted to use 3rd-party types in your pyfunctions, the conversion traits (Serialize, FromPyObject) would have to be implemented by the lib that defines them, but usually isn't. In your crate using pyo3, you can then only work with newtype wrappers, which is ok but not great. In particular, it makes using the same functions/methods also from Rust annoying.

I don't really know of a workaround. But I would never have suspected about the one with inventory, used for avoiding specialization, so who knows... 😄

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing PyO3's existing conversion-trait handling for pyfunctions and the limitations described around third-party types. Investigate whether an approach such as the mentioned inventory workaround can support these conversions without newtype wrappers; done requires an agreed design and implementation path for using third-party types from Rust and Python.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.