PyO3 / PyO3/pyo3

Export Rust traits as Abstract Base Classes (ABCs) on Python

Open
#1,190 3 comments 14 reactions 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

It would be an interesting feature to be able to export traits from Rust to Python, perhaps with a #[pytrait] macro, or with some modification to #[pyclass]. I think this could be best solved with Python's Abstract Base Classes.

When this was proposed on gitter, @davidhewitt suggested that this should be experimented in a new crate, which could later be merged into pyo3 if it's popular and stable enough.

I personally won't be able to work on this for now, so I'm opening this to have the tracking issue and in case someone wants to give it a try.

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 experimenting in a new crate, as suggested in the issue, and review how Rust traits could map to Python Abstract Base Classes. The issue does not name files, tests, entry points, or a concrete acceptance criterion; define those boundaries and a successful interoperability example before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api, backend-api-design
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.