python / python/cpython

Improve and maintain `Doc/data/refcounts.dat`

Open
#127,443 30 comments 4 reactions 1 assignee View on GitHub

@picnixz is already working on this.

Since Nov 30, 2024.

docs
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

The Doc/data/refcounts.dat file is sometimes updated and sometimes not. I suggest we try to make it up-to-date as much as possible, at least by adding the functions part of the stable ABI.

In addition, the entries are not sorted alphabetically. While they are semantically sorted, it does not help when adding new entries (where should we put it?). So I suggest to reformat the file once I'm done with adding the new entries.

Finally, I suggest adding a small script that checks whether the file is up-to-date, at least by checking whether the stable ABI is a subset of that file and whether the refcounts.dat is sorted or not (again it will be part of a CI workflow).

The main motivation behind this is to help newcomers in understanding whether a reference is borrowed or not (sometimes the comment doesn't say anything). It could also help in managing a future linter. Note that we have no syntax to indicate whether a reference is stolen or not so we should also improve that part.

cc @vstinner @encukou @Eclips4 @ZeroIntensity

Linked PRs
  • gh-127444
  • gh-127451
  • gh-127496
  • gh-127497
  • gh-127468
  • gh-127476
### Tasks
- [x] Add refcounts entries from the stable ABI (only func entries)
- [x] Allow to specify when a reference is stolen (use "$" instead of "0")
- [x] Add a script for checking whether the file is correctly formatted (check order, syntax, but not advanced format)
- [x] Add a script for checking if the file is up-to-date when a new function is added to the Stable ABI
- [ ] Unify format (sort entries, add blank lines, add space before pointer dereference marker (optional, likely not))
- [ ] Add CI jobs
- [ ] Use a script to auto-generate the refcounts.dat and let the developer fill out the entries

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.