PyO3 / PyO3/pyo3

Contribution opportunity: use Python 3.12 managed dict and weakref

Open
#4,253 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In Python 3.12 type flags were added to make the interpreter automatically handle __dict__ and weakrefs for classes: https://docs.python.org/3.12/c-api/typeobj.html#c.Py_TPFLAGS_MANAGED_DICT

We should be able to switch to these instead of using out own dict_offset and weaklist_offset machinery. It's probably better for performance, and in the long run this would be a nice simplification to the codebase.

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 locating PyO3's existing dict_offset and weaklist_offset machinery, then read the Python 3.12 Py_TPFLAGS_MANAGED_DICT documentation linked in the issue. Determine the affected internals and tests before replacing the offsets; done means the managed flags cover the existing behavior without regressions and the old machinery is removed or no longer needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
devtools
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.